【发布时间】:2016-02-25 09:40:28
【问题描述】:
我想在 python 3 中制作一个简单的测验程序,但我不知道如何让按钮达到我想要的全宽。我正在使用 python 3 和 TKinter 模块来制作窗口和所有按钮。
from tkinter import *
root = Tk()
que_labl = Label(root, text='Question')
choice1 = Button(root, text='Choice one')
choice2 = Button(root, text='Choice one plus one')
choice3 = Button(root, text='Choice 3')
choice4 = Button(root, text='Choice eight divided by 2')
que_labl.grid(row=0, columnspan=2)
choice1.grid(row=2, column=0, sticky=W)
choice2.grid(row=2, column=1, sticky=W)
choice3.grid(row=3, column=0, sticky=W)
choice4.grid(row=3, column=1, sticky=W)
root.mainloop()
代码生成一个像这样的窗口:
【问题讨论】:
-
简单的谷歌搜索会给你正确的答案
-
问问自己“
sticky=W是做什么的?”
标签: python python-3.x button tkinter window