Custom Menus #78
Replies: 5 comments 5 replies
-
This would require creating a custom menu widget, as Tkinter's menu widget doesn't support theming. |
Beta Was this translation helpful? Give feedback.
-
@rdbende I disagree. |
Beta Was this translation helpful? Give feedback.
-
Hope the menu like this too, I think maybe can make a new repo named : "Sun-valley-ttk-widget" and make some special widgets? |
Beta Was this translation helpful? Give feedback.
-
@rdbende @BenjaminTGa Here is an example. Not really good lol. from ctypes import windll
from tkinter import Tk
from tkinter.ttk import Button
from pywinstyles import change_header_color
from sv_ttk import set_theme
menu = Tk()
menu.title("menu") # Set title
menu.iconbitmap("") # Without this line, GetParent function could not get the hwnd
menu.minsize(175, 370) # Set the minsize
menu.overrideredirect(1) # Remove titlebar
menu.resizable(True, False) # Use `resizeable(False, False)`` may make the window crash
set_theme("dark") # Set dark theme
hwnd = windll.user32.GetParent(menu.winfo_id()) # Get hwnd
WS_THICKFRAME = 0x00040000
WS_VISIBLE = 0x10000000
windll.user32.SetWindowLongW(
hwnd, -16, WS_THICKFRAME | WS_VISIBLE
) # Set window to apply round frame
change_header_color(
menu, "#1C1C1C"
) # Set the 6px frame color as same as the window backgrorund
for text in ("New Tab", "New window", "Open", "Save", "Save as", "Save all"): # Example
widget = Button(
menu,
text=text,
)
widget.pack(fill="x", side="top", padx=3, pady=1)
menu.mainloop() |
Beta Was this translation helpful? Give feedback.
-
@BenjaminTGa Also check this: https://github.com/Akascape/CTkMenuBar |
Beta Was this translation helpful? Give feedback.
-
I would like to be able to implement custom Windows 11 styled menus in my Sun Valley application.
Something like this:
And like this when selected:
Is this possible with Sun Valley, and if not, would it be possible to add this as a feature?
Beta Was this translation helpful? Give feedback.
All reactions