I can not set title of top level

前端 未结 1 1152
忘了有多久
忘了有多久 2021-01-26 09:56

I want to set title for TopLevel, but TopLevel shows title of Root. I think that my next script corresponds with examples from TkInter documentation, but gives me bad result. Ca

相关标签:
1条回答
  • 2021-01-26 10:16

    You try to set Toplevel title with:

    master.title = 'Top'
    

    but the correct syntax is:

    master.title('Top')
    

    There are a couple of additional things: You do not need an additional mainloop for the Toplevel window. From the code it looks like you think that the Toplevel is a new application, instantiating it with app = AppTop(master = top). But it's just a new window which runs under the appapp.mainloop().

    AppTop() inherits from tk.Frame() but you never use it. Instead you put all the widgets directly in the Toplevel (master) window. Same goes for Application() as well.

    0 讨论(0)
提交回复
热议问题