GUI tkinter/My主窗口覆盖了我创建的toplavel

GUI tkinter/My主窗口覆盖了我创建的toplavel,tkinter,Tkinter,我正在用tkinter创建应用程序,我用这个问题来修正自己: 我的代码显然没有问题,但主窗口与toplavel重叠,注意:我已经尝试使用focus(所有可能的)。 代码如下: from tkinter import * root = Tk() root.title("Tecl De Des") root.geometry("800x600+275+50") winfo_screen_X = root.winfo_screenwidth() winfo_screen_Y = root.

我正在用tkinter创建应用程序,我用这个问题来修正自己:

我的代码显然没有问题,但主窗口与toplavel重叠,注意:我已经尝试使用focus(所有可能的)。 代码如下:

 from tkinter import *
 root = Tk()
 root.title("Tecl De Des")
 root.geometry("800x600+275+50")
 winfo_screen_X = root.winfo_screenwidth()
 winfo_screen_Y = root.winfo_screenheight()
 class Teclado(object):
     def __init__(self,root):
         self.toplvl = Toplevel(root)
         self.toplvl.geometry("250x200+{}+{}".format(winfo_screen_X//2 - 150, winfo_screen_Y//2 -100))
         self.toplvl.mainloop()
 class rom():
     pass
 Teclado(root)
 root.mainloop()

如果要将
toplevel
窗口保持在其父窗口的顶部,可以使用

self.toplvl.transient(root)
Teclado
类的
\uuuuu init\uuuuuuu()内部


您也不需要调用self.toplvl.mainloop()

您可以提供一个ss吗?