{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Stylesheet editor\n\nGUI for live coding of a Qt stylesheet document.\n\nThis GUI can be used to live adjust a ``qss`` stylesheet\nand directly see the changes for many widgets (Qt and itom\nspecific).\n\nUsage:\n\nExecute this script to load the demo GUI. This GUI consists\nof a stylesheet editor widget in a left toolbar and many\nwidgets, that are often used within ``itom``.\n\nIf you stylesheet depends on icons within a rcc resource file,\nclick the \"load resources\" button to load icons from a rcc\nresource file, first. Then paste your desired stylesheet into\nthe editor. Whenever you want to update the GUI click the update button.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from itomUi import (\n ItomUi,\n) # import the base class ItomUi from the module itomUi in the itom-packages subfolder\nfrom itom import ui\nfrom itom import dataObject\n\n\n\nclass StyleSheetEditor(ItomUi): # StyleCreator is inherited from ItomUi\n def __init__(self): # constructor\n\n # call constructor of ItomUi like it would be the constructor of the class itom.ui:\n ItomUi.__init__(self, \"stylesheetEditor.ui\", ui.TYPEWINDOW)\n\n # initialize some plots\n self.gui.itom1DQwtPlot[\"source\"] = dataObject.rand([4, 500], \"uint16\")\n\n self.gui.itom2dQwtPlot[\"source\"] = dataObject.randN([100, 512, 768], \"uint8\")\n self.gui.itom2dQwtPlot[\"overlayImage\"] = dataObject.rand([512, 768], \"float32\")\n self.gui.itom2dQwtPlot_2[\"source\"] = dataObject.randN([100, 512, 768], \"uint8\")\n self.gui.itom2dQwtPlot_2[\"overlayImage\"] = dataObject.randN([512, 768], \"float32\")\n\n self.gui.call(\"statusBar\").call(\"showMessage\", \"Status bar message...\")\n\n @ItomUi.autoslot(\"\") # the signal is clicked()\n def on_btnUpdate_clicked(self):\n # apply the current content of the text field to the stylesheet\n self.gui[\"styleSheet\"] = self.gui.txtStyle[\"plainText\"]\n\n @ItomUi.autoslot(\"\")\n def on_btnLoadRcc_clicked(self):\n rccFile = ui.getOpenFileName(\n \"RCC Resource File\",\n filters=\"RCC Resource File (*.rcc)\",\n parent=self.gui,\n )\n\n if rccFile is not None:\n unregisterResource(rccFile)\n\n if not registerResource(rccFile):\n ui.msgCritical(\"Error\", f\"Could not load resource file '{rccFile}'\")\n\n\nhmi = StyleSheetEditor()\nhmi.gui.show()\n\n# print(\"Text from python command line\")\n# raise RuntimeError(\"Error text from python command line\")\n# itom.clc()" ] }, { "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 }