【发布时间】:2021-01-16 00:12:12
【问题描述】:
我正在为我正在为项目创建的程序制作 gui。我在同一行中制作了多个按钮,是否可以在一个类中执行此操作,这样我就不必不断重复代码?谢谢
flashcards.config(height = 15, width = 45 )
flashcards.place(x=1, y=600)
cMinigames = tk.Button(text="Core Minigames", bg="DarkSeaGreen1", fg="ghost white")
cMinigames.config(height = 15, width = 45)
cMinigames.place(x=300, y=600)
timetables = tk.Button(text="Timetables", bg="DarkSeaGreen1", fg="ghost white")
timetables.config(height = 15, width = 45 )
timetables.place(x=600, y=600)
quizzes = tk.Button(text="Quizzes", bg="DarkSeaGreen1", fg="ghost white")
quizzes.config(height = 15, width = 45 )
quizzes.place(x=900, y=600)
pmf = tk.Button(text="Pick My Focus!", bg="DarkSeaGreen1", fg="ghost white")
pmf.config(height = 15, width = 50 )
pmf.place(x=1200, y=600)```
【问题讨论】:
-
for i in range(x):tk.Button().pack()
标签: python python-3.x oop tkinter