Removing minimize/maximize buttons in Tkinter

前端 未结 3 1825
没有蜡笔的小新
没有蜡笔的小新 2020-11-30 08:44

I have a python program which opens a new windows to display some \'about\' information. This window has its own close button, and I have made it non-resizeable. However, th

3条回答
  •  余生分开走
    2020-11-30 09:33

    In general, what decorations the WM (window manager) decides to display can not be easily dictated by a toolkit like Tkinter. So let me summarize what I know plus what I found:

    import Tkinter as tk
    
    root= tk.Tk()
    
    root.title("wm min/max")
    
    # this removes the maximize button
    root.resizable(0,0)
    
    # # if on MS Windows, this might do the trick,
    # # but I wouldn't know:
    # root.attributes(toolwindow=1)
    
    # # for no window manager decorations at all:
    # root.overrideredirect(1)
    # # useful for something like a splash screen
    
    root.mainloop()
    

    There is also the possibility that, for a Toplevel window other than the root one, you can do:

    toplevel.transient(1)
    

    and this will remove the min/max buttons, but it also depends on the window manager. From what I read, the MS Windows WM does remove them.

提交回复
热议问题