bre*_*da 4 python position tkinter button
我这里有一个程序,里面有两个按钮。我正在尝试将它们的位置更改为它们之间的空间,因为目前它们直接位于彼此下方。我应该怎么做才能改变按钮的位置?
def menu():
import tkinter
window=tkinter.Tk()
window.title('Lightning Parties')
window.configure(background='turquoise')
lbl=tkinter.Label(window, text='Welcome to Lightning Parties!', fg='purple', bg='turquoise', font=('comicsans', 14))
lbl.pack()
#here are the buttons
lbl=tkinter.Button(window, text='Returning customer options', fg='white', bg='purple', font=('comicsans', 12),command=combine_funcs(window.destroy, customer_login))
lbl.pack()
lbl=tkinter.Button(window, text='Register as a customer', fg='white', bg='purple', font=('comicsans', 12),command=combine_funcs(window.destroy, customer_details))
lbl.pack()
Run Code Online (Sandbox Code Playgroud)
任何帮助将不胜感激!
其实上学期我也做了一些Tkinter的应用,这是老师给我们的项目。所以我访问了一些 Python 教程网站,找到了三种将小部件放置在输出屏幕上的方法。这三种方法是
1. Pack()
2. Grid()
3. Place() #the best method over Pack() and Grid()
Run Code Online (Sandbox Code Playgroud)
Place() 方法以 x 和 y 的形式获取坐标。有关更多说明,请参阅此链接https://www.tutorialspoint.com/python/python_gui_programming.htm
https://www.tutorialspoint.com/python/tk_place.htm
请参阅给定链接的页面底部。Place() 方法是用其适当的参数定义的。与 Pack() 和 Grid() 相比,我更喜欢 Place() 方法,因为它的工作方式类似于我们在 html 中使用的 CSS,因为它采用 (width,height) 的值并根据您的需要放置小部件。
如果您找到答案,将不胜感激。