{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Splitter\n\nThis demo shows how to manipulate a splitter, set as layout in QtDesigner.\n\n.. hint::\n\n This demo uses specially wrapped methods of QSplitter. For more information see\n section ``Calling slots`` in https://itom.bitbucket.io/latest/docs/06_extended_gui/qtdesigner.html)\n These methods are indiciated by #-> special method call\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\n\n\n\nclass SplitterDemo(ItomUi): # ListWidgetDemo is inherited from ItomUi\n def __init__(self): # constructor\n # call constructor of ItomUi like it would be the constructor of the class itom.ui:\n ItomUi.__init__(self, \"splitterDemo.ui\", ui.TYPEWINDOW)\n\n self.gui.splitter.call(\"setStretchFactor\", 0, 3) # -> special method call\n self.gui.splitter.call(\"setStretchFactor\", 1, 1) # -> special method call\n self.gui.splitter.call(\"setCollapsible\", 0, False) # -> special method call\n self.gui.splitter.call(\"setCollapsible\", 1, True) # -> special method call\n print(\n \"Top section. Collapsible:\",\n self.gui.splitter.call(\"isCollapsible\", 0),\n ) # -> special method call\n print(\n \"Bottom section. Collapsible:\",\n self.gui.splitter.call(\"isCollapsible\", 1),\n ) # -> special method call\n\n # it is also possible to set the sizes of the sections using\n # self.gui.splitter.call(\"setSizes\", (200, 300)) #-> special method call\n\n # or read it\n # print(self.gui.splitter.call(\"sizes\")) #-> special method call\n\n\n# create a first instance of ListWidgetDemo and the gui\nwin1 = SplitterDemo()\nwin1.gui.show() # show the gui" ] } ], "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 }