12.1.10.10.1. Horizontal Box LayoutΒΆ

1.9488317966461182
2.0629541873931885
2.1759161949157715

from itom import ui
from itom import uiItem
import time


t0 = time.time()

gui: ui = ui("layoutExample.ui", type=ui.TYPEWINDOW)

num = 100
t = time.time()
for i in range(num):
    hlayout: uiItem = gui.horLayout  # access the layout item
print(time.time()-t)
t = time.time()

for i in range(num):
    hlayout = gui.getChild("horLayout")
print(time.time()-t)

# remove the 2nd widget at index position 1
hlayout.call("removeItemAt", 1)

# add a new radio button at the end
className: str = "QRadioButton"
objName: str = "newRadioButton"
radioBtn: uiItem = hlayout.call("addItem", className, objName)
radioBtn["text"] = "new option"
radioBtn["checked"] = True

# insert a spin box at index position 1
idx: int = 1  # insert at this position
className: str = "QSpinBox"
objName: str = "mySpinBox"
spinBox: uiItem = hlayout.call("insertItem", idx, className, objName)
spinBox["value"] = 7

print(time.time() - t)
gui.show()  # show the user interface

Total running time of the script: ( 0 minutes 4.192 seconds)