[英]Python tkSimpleDialog Fullscreen and Focus Over Fullscreen Parent
我在讓tkSimpleDialog專注於全屏窗口GUI時遇到問題。 我有一個GUI,我試圖使用對話框窗口作為管理員密碼來使用root.quit()關閉該GUI(例如信息亭模式的應用程序)。 問題是如果父窗口是全屏的,則對話框不會出現在父窗口的前面。 另外,我也想使tkSimpleDialog變為全屏顯示。
這是在我的程序中使用tkSimpleDialog.py調用/創建對話框的代碼:
def check_admin_password():
# use askstring here to verify password.
pass_attempt = simpledialog.askstring("Verifying access","Please enter Admin password", parent=window, show="*")
if pass_attempt == "password":
root.quit() # used whatever your instance of Tk() is here in place of root.
admin_minimize_button = Button(window, text = "Administrator", command = check_admin_password, width=35, height=12)
admin_minimize_button.grid(row=4, column=0)
我在父窗口中使用以下代碼,並且我相信overrideredirect(True)會影響我的對話框窗口的焦點:
qwindow = Toplevel(root) #renames Toplevel "popup" window frame to variable "qwindow"
qwindow.title('Mission Queue') #creates title on popup window
w, h = qwindow.winfo_screenwidth(), qwindow.winfo_screenheight() #aquires dimensions from display size
qwindow.geometry("%dx%d+0+0" % (w, h)) #sets window size to aquired dimensions
qwindow.overrideredirect(True) #removes top bar and exit button from parent window frame
我嘗試編輯tkSimpleDialog.py文件並添加overrideredirect(True)行,但是這行不通。 如果需要更多信息,請告訴我。 任何建議將不勝感激。 提前致謝。
由於無法使用tkSimpleDialog找出解決方案,因此嘗試使用另一種方法來創建自己的“對話框”。 不幸的是,我仍然無法獲得對話框來使輸入行聚焦,而將屏幕窗口設置為wm_attributes('-fullscreen', 'True')
和overrideredirect(True)
。 最好同時做兩個工作; 出於我的目的,在我的應用程序中僅使用全屏模式,而不使用overrideredirect(True)
會很好。 對於有類似問題或希望查看有關我的進度的更多文檔的人,請點擊以下指向我其他論壇帖子的鏈接:( 具有Overrideredirect和Fullscreen的Tkinter Entry Widget )。 謝謝您的幫助!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.