我正在開發一個具有“登錄頁面”的python程式,現在只有一個登錄按鈕,因為我沒有添加輸入區域(密碼和用戶名)等,并添加了一個占位符按鈕,當你按它應該帶你到某種主頁。現在問題來了。該按鈕在視窗下方呈現。正如您在螢屏截圖中看到的那樣,無法找到該按鈕,因為它位于第二張圖片中所示的位置。(通過制作找到此資訊,以便我可以全屏顯示視窗,然后在底部找到它)
這是代碼,如果您想查看它。
import tkinter as tk
import time
import math
win = tk.Tk()
win.geometry("650x450")
win.resizable(height = False, width = False)
win.configure(background="black")
Signin = tk.Frame(win)
Homepage = tk.Frame(win)
def change_to_Signin():
win.title("DNO - Sign In")
Signin.pack(fill="both", expand=1)
Homepage.pack_forget()
def change_to_Homepage():
win.title("DNO - Homepage")
Homepage.pack(fill="both", expand=1)
Signin.pack_forget()
change_to_Signin()
hp_title = tk.Label(Signin, bg="#3e3e3e", text=" Sign In", fg="White", font=('Helvetica bold',25), width=650, height=4, anchor="w").pack(pady=(0, 385))
hp_swapbutton = tk.Button(Signin, text="Sign in", command=change_to_Homepage, font=('Helvetica bold',15)).pack()
#btnP1 = tk.Button(Signin, text = "Sign In", command = change_to_Homepage).pack()
#btnP2 = tk.Button(Homepage, text = "Sign Out", command = change_to_Signin).pack()
win.mainloop()

place相反,如果您希望按鈕在視窗中居中,因為您可以輕松安全地使用相對坐標的其他小部件很少:
hp_swapbutton = tk.Button(Signin, text="Sign in", command=change_to_Homepage, font=('Helvetica bold',15))
hp_swapbutton.place(relx=.5, rely=.5, anchor="center")

轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/519339.html
上一篇:關于事件回圈如何在Pysimplegui中作業的任何想法?無法根據其他輸入確定禁用按鈕
下一篇:顫振布爾是正確的,但不改變物理?
