cleanup for theming widgets
This commit is contained in:
parent
dcdcb6a711
commit
5dbd34f230
3 changed files with 14 additions and 12 deletions
|
@ -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", "<<ThemeChanged>>", themes.theme_change_menu)
|
||||
self.master.bind("<<ThemeChanged>>", themes.theme_change)
|
||||
self.style.theme_use(self.guiconfig["preferences"]["theme"])
|
||||
func = partial(themes.theme_change_menu, self.style)
|
||||
self.master.bind_class("Menu", "<<ThemeChanged>>", func)
|
||||
func = partial(themes.theme_change, self.style)
|
||||
self.master.bind("<<ThemeChanged>>", func)
|
||||
|
||||
def setup_app(self):
|
||||
self.master.title("CORE")
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Add table
Reference in a new issue