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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
| from tkinter import *
def create_frame(master, t):
L = 400
H = 600
frame = Frame(master, bd=2, bg="beige")#, relief=SUNKEN)
t = "mon lab"
monText = Text(frame)
newBtn = Button(toolbar, text="Tableau", bg="maroon", fg="white", borderwidth=3, command=myClass)
newBtn.pack(side=LEFT, fill=X)
root.geometry('{}x{}'.format(L, H))
root.minsize(L, H)
root.update_idletasks()
print(root.winfo_width())
print(frame.winfo_width())
return frame
if __name__ == '__main__':
class myClass(Tk):
def __init__(self, *args, **kwargs):
for w in frame1.winfo_children():
w.destroy()
n=0
i = 0
TBtn0 = 0
text = Frame(root, bg='maroon')
text.pack(fill=X)
root.update()
#print(text.winfo_width())
while i<51 :
myBt= "bt"+str(n)
myBt = Button(text, text=i, background="red")
myBt.pack(side=LEFT)
root.update()
TBtn = myBt.winfo_width()
TBtn0 = TBtn0 + TBtn
if TBtn0<root.winfo_width():
pass
print(str(n)+ " - " + str(TBtn))
n=n+1
pass
else :
#print(TBtn)
myBt.destroy()
root.update()
text = Frame(root, bg='maroon')
text.pack(fill=X)
root.update()
myBt= Button(text, text=i, background="red")
myBt.pack(side=LEFT)
root.update()
TBtn0 = myBt.winfo_width()
n=n+1
i = i+1
#print(root.winfo_width())
#app.mainloop()
root = Tk()
color= "lightyellow"
root.title("Syntax Analyser")
#root.minsize(width=400, height=400)
#root.maxsize(width=400, height=400)
myWidth = 25 #largeur des boutons du menu
myHeight = 25 #hauteur des boutons du menu
myColor="lightblue"
toolbar = Frame(root, borderwidth=2, relief='raised', background=myColor)
toolbar2 = Frame(root, borderwidth=2, relief='raised', background=myColor)
toolbar.pack(side=TOP, fill=X)
toolbar2.pack(side=TOP, fill=X)
root.update()
numero=1
frame1 = create_frame(root, numero)
# Fin du menu deroulant #############################################
root.configure(background="green")
root.mainloop() |
Partager