diff --git a/coretk/coretk/app.py b/coretk/coretk/app.py index 7c2562a9..c8d4e597 100644 --- a/coretk/coretk/app.py +++ b/coretk/coretk/app.py @@ -1,6 +1,5 @@ import logging import tkinter as tk -from functools import partial from tkinter import ttk from coretk import appconfig, themes @@ -42,11 +41,9 @@ class Application(tk.Frame): def setup_theme(self): themes.load(self.style) + self.master.bind_class("Menu", "<>", themes.theme_change_menu) + self.master.bind("<>", themes.theme_change) self.style.theme_use(self.guiconfig["preferences"]["theme"]) - func = partial(themes.theme_change_menu, self.style) - self.master.bind_class("Menu", "<>", func) - func = partial(themes.theme_change, self.style) - self.master.bind("<>", func) def setup_app(self): self.master.title("CORE") diff --git a/coretk/coretk/graph/node.py b/coretk/coretk/graph/node.py index 105e21b7..e9f59882 100644 --- a/coretk/coretk/graph/node.py +++ b/coretk/coretk/graph/node.py @@ -168,7 +168,7 @@ class CanvasNode: is_wlan = self.core_node.type == NodeType.WIRELESS_LAN is_emane = self.core_node.type == NodeType.EMANE context = tk.Menu(self.canvas) - themes.style_menu(self.app.style, context) + themes.style_menu(context) if self.app.core.is_runtime(): context.add_command(label="Configure", command=self.show_config) if NodeUtils.is_container_node(self.core_node.type): diff --git a/coretk/coretk/themes.py b/coretk/coretk/themes.py index 55b5732d..66565f8d 100644 --- a/coretk/coretk/themes.py +++ b/coretk/coretk/themes.py @@ -141,13 +141,14 @@ def load(style): ) -def theme_change_menu(style, event): +def theme_change_menu(event): if not isinstance(event.widget, tk.Menu): return - style_menu(style, event.widget) + style_menu(event.widget) -def style_menu(style, widget): +def style_menu(widget): + style = ttk.Style() bg = style.lookup(".", "background") fg = style.lookup(".", "foreground") abg = style.lookup(".", "lightcolor") @@ -162,17 +163,21 @@ def style_listbox(widget): style = ttk.Style() bg = style.lookup(".", "background") fg = style.lookup(".", "foreground") + bc = style.lookup(".", "bordercolor") + if not bc: + bc = "black" widget.config( background=bg, foreground=fg, highlightthickness=1, - highlightcolor="black", - highlightbackground="black", + highlightcolor=bc, + highlightbackground=bc, bd=0, ) -def theme_change(style, event): +def theme_change(event): + style = ttk.Style() style.configure(Styles.picker_button, font=("TkDefaultFont", 8, "normal")) style.configure( Styles.green_alert,