嘿傢伙我有一個問題,我一直在尋找答案,但我似乎無法解決我的問題。tkinter Python中的按鈕位置(網格)
我想將我的「Enter」和「Quit」按鈕更多地移動到窗口底部,但我不確定我是否理解網格功能。
我在窗口內製作了兩個框架,按鈕位於底部框架中,但我似乎無法使用行功能讓它們更低。
我就像剛開始使用Python和有規劃的經驗,所以這是我的第一個項目。(請不要笑)
#import tkinder module
from tkinter import *
#make frame
root = Tk()
root.geometry("600x300")
top_frame = Frame(root)
bottom_frame = Frame(root)
top_frame.pack()
bottom_frame.pack()
#headline
headline = Label(top_frame, text="Welcome to PrintAssistant.", bg='blue', fg='white')
headline.config(font=('Courier', 27))
headline.grid(padx=10, pady=10)
Name = Label(bottom_frame, text="Name:", fg='blue')
Name.config(font=('Courier', 20))
Name.grid(row=1)
Password = Label(bottom_frame, text="Password:", fg='blue')
Password.config(font=('Courier', 20))
Password.grid(row=2)
Name_entry = Entry(bottom_frame)
Name_entry.grid(row=1, column=1)
Password_entry = Entry(bottom_frame)
Password_entry.grid(row=2, column=1)
#enter_button
enter_button = Button(bottom_frame, text="Enter", bg='blue', fg='white')
enter_button.config(height = 2, width = 15)
enter_button.grid(sticky = S)
#quit_button
quit_button = Button(bottom_frame, text="Quit", bg="blue", fg="white")
quit_button.config(height = 2, width = 15)
quit_button.grid(sticky = S)
root.mainloop()
非常感謝您的幫助!,我嘗試了所有,但是墊片會做! – Spaarwiel