{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Main form\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from itom import ui\nfrom itom import uiItem\n\n\ngui: ui = ui(\"mainForm.ui\", type=ui.TYPEWINDOW)\nvlayout: uiItem = gui.vlayout\n\n\n# add 10 items from item.ui\nfor i in range(0, 10):\n # all object names of the added widget including\n # its child widgets and layouts are modified by\n # the following suffix:\n objNameSuffix: str = f\"_{i}\"\n \n # ctrlItem is the reference to the newly added outer widget\n ctrlItem: uiItem = vlayout.call(\"addItemFromUiFile\", \"item.ui\", objNameSuffix)\n \n # print the name of all newly added child widgets\n print(ctrlItem.children())\n \n # access the newly added label\n lbl: uiItem = ctrlItem.getChild(\"label\" + objNameSuffix)\n lbl[\"text\"] = f\"Item {i+1}\"\n \n # alternate the check state of the LedStatus\n led: uiItem = ctrlItem.getChild(\"led\" + objNameSuffix)\n led[\"checked\"] = i % 2\n \n # change the checkstate of some checkboxes\n # the enable state of the corresponding spinboxes\n # is automatically changed due to the signal/slot \n # connection, created in QtDesigner.\n checkbox: uiItem = ctrlItem.getChild(\"checkBox\" + objNameSuffix)\n checkbox[\"checked\"] = i % 3\n\n# show the gui\ngui.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\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 }