【发布时间】:2021-07-05 23:59:31
【问题描述】:
我正在尝试创建这个程序,基本上我需要在 tkinter 中制作 8 行按钮 但我不知道我怎么能用循环做到这一点 ,没有循环我这样做了:
def decimal():
app = Toplevel(root)
app.title("Traducteur décimal")
app.geometry("400x200")
r1 = Button(app, text="LED 1 ON")
r2 = Button(app, text="LED 1 OFF")
r1.place(x=125,y=0)
r2.place(x=225,y=0)
r3 = Button(app, text="LED 2 ON")
r4 = Button(app, text="LED 2 OFF")
r3.place(x=125, y=40)
r4.place(x=225, y=40)
r5 = Button(app, text="LED 3 ON")
r6 = Button(app, text="LED 3 OFF")
r5.place(x=125, y=80)
r6.place(x=225, y=80)
顺便说一句,我很抱歉英语不好。 谢谢
【问题讨论】:
-
顺便说一句,我知道这可以通过面向对象编程实现,但我对它的经验很少
-
使用
grid(),你会更快得到更好的答案。