python - Removing minimize/maximize buttons in Tkinter - Stack Overflow

PHOTO EMBED

Wed Oct 05 2022 20:49:18 GMT+0000 (Coordinated Universal Time)

Saved by @milan104 #python

    import ctypes as ct

    set_window_pos = ct.windll.user32.SetWindowPos
    set_window_long = ct.windll.user32.SetWindowLongPtrW
    get_window_long = ct.windll.user32.GetWindowLongPtrW
    get_parent = ct.windll.user32.GetParent

    # Identifiers
    gwl_style = -16

    ws_minimizebox = 131072
    ws_maximizebox = 65536

    swp_nozorder = 4
    swp_nomove = 2
    swp_nosize = 1
    swp_framechanged = 32

    hwnd = get_parent(settings_panel.winfo_id())
    # Get the style
    old_style = get_window_long(hwnd, gwl_style)
    # New style, without max/min buttons
    new_style = old_style & ~ ws_maximizebox & ~ ws_minimizebox
    # Apply the new style
    set_window_long(hwnd, gwl_style, new_style)
    # Updates
    set_window_pos(hwnd, 0, 0, 0, 0, 0, swp_nomove | swp_nosize | swp_nozorder | swp_framechanged)
content_copyCOPY

https://stackoverflow.com/questions/2969870/removing-minimize-maximize-buttons-in-tkinter