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
|
import tkinter as tk
fen1 = tk.Frame()
fen1.pack()
fen = tk.Frame()
fen.pack()
for ien in range(12):
btn = tk.Button(fen1, text=str(ien), bg="black", bd=3,
command=lambda x=ien: num_bt(x), height=10, width=3,
cursor="hand1", activebackground="lightblue",
activeforeground="red", relief="groove")
btn.pack(side="left")
def num_bt(x):
print(x)
bts = []
for ind in range(21):
bt = tk.Button(fen, text=str(ind), bg="ivory", bd=3,
command=lambda x=ind: num_bt(x), height=10, width=3,
cursor="hand1", activebackground="lightblue",
activeforeground="red", relief="groove")
bt.pack(side="left")
bts.append(bt)
tk.mainloop() |
Partager