1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| import Tix as tk
def AddChild(label,parent = None):
global tree,img,name_dicco
if label in names_dicco.keys():
return 0
if parent == None:
#no parent, root level
_name = tree.hlist.add(label,text = label)
else:
#there is a parent, let's do a child
_name = tree.hlist.add_child(parent = names_dicco[parent],text = label)
names_dicco[label] = _name
return 1
root = tk.Tk()
root.geometry("+50+50")
tree = tk.Tree(root,width = 640,height = 480)
tree.grid()
img = tree.tk.call('tix', 'getimage', 'file')
names_dicco = {}
for idx in range(1,11):
label = "DynamicPage%02u"%(idx)
AddChild(label)
AddChild("MainMenu")
AddChild("Parameters","MainMenu")
AddChild("Display","Parameters")
AddChild("Line 1","Display")
AddChild("L1ProcVar","Line 1")
AddChild("L1FavUnit","Line 1")
AddChild("L1Filter","Line 1")
AddChild("Line 2","Display")
AddChild("L2ProcVar","Line 2")
AddChild("L2FavUnit","Line 2")
AddChild("L2Filter","Line 2")
AddChild("Calibration","MainMenu")
AddChild("CalPoint1","Calibration")
AddChild("CalPoint2","Calibration")
AddChild("CalSave","Calibration")
AddChild("Test","MainMenu")
tree.mainloop() |
Partager