Python按钮对齐

时间:2015-02-06 05:46:41

标签: python tkinter

我通过PyCharm使用TKinter遇到了问题。 按钮放置继续运行。

我已经尝试了网格和打包但没有运气。 甚至排,锚,但我不断得到不同的结果。

Keep on failing

jay = Tk()
jay.title("Awesome Software")
jay.geometry("720x560")

searchbutton = Button(jay, text="Setting")
searchbutton.pack(side=TOP)

stopbutton = Button(jay, text="Stop")
stopbutton.pack(side=TOP)

setbutton = Button(jay, text="Search")
setbutton.pack(side=TOP)

mainloop()

1 个答案:

答案 0 :(得分:1)

找到它,

jay = Tk()
jay.title("Awesome Software")
jay.geometry("720x560")

but_frame = Frame(jay)
searchbutton = Button(but_frame, text="Search")
searchbutton.pack(side=TOP, padx=20,pady=10)

stopbutton = Button(but_frame, text="Stop")
stopbutton.pack(side=TOP,pady=10)

setbutton = Button(but_frame, text="Settings")
setbutton.pack(side=TOP,pady=10)

but_frame.pack(side=LEFT)

mainloop()

构建框架然后执行