{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Plot style sheets\n\nThis demo shows how you can set and change the theme of your GUI.\nThe style can not be entirely removed to the windows, mac or plastique style\n(usually done by ``setStyle(new QWindowsStyle())``). \nIt only resets the style sheet to an empty one, such that the native fallbacks to the\nos dependent style is applied. However, ``Qt::WA_StyledBackground`` is still active.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from itom import dataObject\nfrom itom import ui\nfrom itomUi import ItomUi\nimport inspect\nimport os.path\nimport numpy as np\n\n\nclass PlotStyleSheets(ItomUi):\n def __init__(self):\n ownFilename = inspect.getfile(inspect.currentframe())\n ownDir = os.path.dirname(ownFilename)\n uiFile = os.path.join(ownDir, \"demoPlotStyleSheets.ui\")\n uiFile = os.path.abspath(uiFile)\n ItomUi.__init__(self, uiFile, ui.TYPEWINDOW, childOfMainWindow=True)\n obj = dataObject.randN([1024, 1024], \"float32\")\n obj[200:300, 200:300] = float(\"nan\")\n self.gui.plot2d[\"source\"] = obj\n self.gui.plot1d[\"source\"] = dataObject(np.sin(np.arange(0, 10 * np.pi, (1 / 20) * np.pi)))\n\n def show(self, modalLevel: int = 0):\n self.gui.show(modalLevel)\n\n @ItomUi.autoslot(\"\")\n def on_radioNoStyle_clicked(self):\n self.gui[\"styleSheet\"] = \"\"\n self.gui.plot2d[\"backgroundColor\"] = \"#ffffff\"\n self.gui.plot2d[\"axisColor\"] = \"#000000\"\n self.gui.plot2d[\"textColor\"] = \"#000000\"\n self.gui.plot2d[\"canvasColor\"] = \"#ffffff\"\n self.gui.plot1d[\"backgroundColor\"] = \"#ffffff\"\n self.gui.plot1d[\"axisColor\"] = \"#000000\"\n self.gui.plot1d[\"textColor\"] = \"#000000\"\n self.gui.plot1d[\"canvasColor\"] = \"#ffffff\"\n\n @ItomUi.autoslot(\"\")\n def on_radioDarkStyle_clicked(self):\n with open(\"darkorange.qss\", \"rt\") as f:\n self.gui[\"styleSheet\"] = f.read()\n self.gui.plot2d[\"backgroundColor\"] = \"#323232\"\n self.gui.plot2d[\"axisColor\"] = \"#ffffff\"\n self.gui.plot2d[\"textColor\"] = \"#ffffff\"\n self.gui.plot2d[\"canvasColor\"] = \"#323232\"\n self.gui.plot1d[\"backgroundColor\"] = \"#323232\"\n self.gui.plot1d[\"axisColor\"] = \"#ffffff\"\n self.gui.plot1d[\"textColor\"] = \"#ffffff\"\n self.gui.plot1d[\"canvasColor\"] = \"#323232\"\n\n @ItomUi.autoslot(\"\")\n def on_radioButtonBright_clicked(self):\n self.gui.plot2d[\"buttonSet\"] = \"StyleBright\"\n self.gui.plot1d[\"buttonSet\"] = \"StyleBright\"\n\n @ItomUi.autoslot(\"\")\n def on_radioButtonDark_clicked(self):\n self.gui.plot2d[\"buttonSet\"] = \"StyleDark\"\n self.gui.plot1d[\"buttonSet\"] = \"StyleDark\"\n\n\nif __name__ == \"__main__\":\n instance = PlotStyleSheets()\n instance.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n\n" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.10" } }, "nbformat": 4, "nbformat_minor": 0 }