10 Şubat 2015 Salı

How to build a non class app

>>> def a(words) : print words   
>>> x={}
>>> x["f"] = a
>>> x["f"]("deneme")
deneme #result

so if want to build non class app you need use a dict of per class.

but = Button(self.root,text:"dont click me !")
but.place(x=0,y=0,width=100)

gui_dict = {}
for i in range(4):
    temp_button = but
    temp_button.config(text=but.config('text')[-1].split(" ")[i])
    temp_button.config(x=((i+100)+10),y=40)
    gui_dict["button%0.2d"%(i+1)]  = temp_button #namespace

now you got 4 button :
names is : 'button01','button02','button03','button04'
text is : "dont","click","me","!"
for command,  need a tuple for recall

easy edit after any actions :
f = (1,2,3,4)
for e in range(len(gui_dict.keys())):
    gui_dict["button%0.2d"%(i+1)].config(text="%0.1d"%f[e])
   

Hiç yorum yok:

Yorum Gönder