{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Horizontal Box Layout\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from itom import ui\nfrom itom import uiItem\nimport time\n\n\nt0 = time.time()\n\ngui: ui = ui(\"layoutExample.ui\", type=ui.TYPEWINDOW)\n\nnum = 100\nt = time.time()\nfor i in range(num):\n hlayout: uiItem = gui.horLayout # access the layout item\nprint(time.time()-t)\nt = time.time()\n\nfor i in range(num):\n hlayout = gui.getChild(\"horLayout\")\nprint(time.time()-t)\n\n# remove the 2nd widget at index position 1\nhlayout.call(\"removeItemAt\", 1)\n\n# add a new radio button at the end\nclassName: str = \"QRadioButton\"\nobjName: str = \"newRadioButton\"\nradioBtn: uiItem = hlayout.call(\"addItem\", className, objName)\nradioBtn[\"text\"] = \"new option\"\nradioBtn[\"checked\"] = True\n\n# insert a spin box at index position 1\nidx: int = 1 # insert at this position\nclassName: str = \"QSpinBox\"\nobjName: str = \"mySpinBox\"\nspinBox: uiItem = hlayout.call(\"insertItem\", idx, className, objName)\nspinBox[\"value\"] = 7\n\nprint(time.time() - t)\ngui.show() # show the user interface" ] } ], "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 }