import ctypes as ct from tkinter import * def setWinStyle(root): 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(root.winfo_id()) old_style = get_window_long(hwnd, gwl_style) # Get the style new_style = old_style & ~ ws_maximizebox & ~ ws_minimizebox # New style, without max/min buttons set_window_long(hwnd, gwl_style, new_style) # Apply the new style set_window_pos(hwnd, 0, 0, 0, 0, 0, swp_nomove | swp_nosize | swp_nozorder | swp_framechanged) # Updates window = Tk() Button(window, text="button").pack() # add your widgets here. window.after(10, lambda: setWinStyle(window)) #call to change style after the mainloop started. Directly call setWinStyle will not work. window.mainloop()
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter