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
|
from tkinter import *
from tkinter import ttk
master = Tk()
L = master.winfo_screenwidth()
H = master.winfo_screenheight()
bout=[]
mesFrames=[]
master.minsize(L,H)
motsManquants=[]
class MyButton(Button):
def on_click(self):
print(int(b.winfo_reqwidth()))
print(mesFrames)
def callback() :
conteneur = Frame(master, bg='green', width=60)
conteneur.pack()
n = 0
texte = [("HG","Et"),("MB","je")]
for mot2 in texte :
mot = mot2[1]
frame = Frame(conteneur, bg='grey', width=master.winfo_screenwidth(), height=130)
frame.pack(expand=True)
mesFrames.append(frame)
w = MyButton(text=mot, font='arial 16', fg="black", bg="yellow")#, command=lambda j=n: OnButton2Click(j))
w['command'] = w.on_click
w.pack(in_=frame, side='left')
w1=(w, n, mot)
bout.append(w1)
b = Button(master, text="OK", width=120, command=callback)
b.pack()
mainloop() |
Partager