updated framescroll to dynamically set bg based on current style
This commit is contained in:
parent
08927b180a
commit
d63da73581
7 changed files with 17 additions and 24 deletions
|
@ -40,8 +40,6 @@ class Application(tk.Frame):
|
|||
self.style.theme_use(themes.DARK)
|
||||
func = partial(themes.update_menu, self.style)
|
||||
self.master.bind_class("Menu", "<<ThemeChanged>>", func)
|
||||
func = partial(themes.update_toplevel, self.style)
|
||||
self.master.bind_class("Toplevel", "<<ThemeChanged>>", func)
|
||||
|
||||
def setup_app(self):
|
||||
self.master.title("CORE")
|
||||
|
|
|
@ -35,7 +35,7 @@ class ServicesSelectDialog(Dialog):
|
|||
self.groups.listbox.selection_set(0)
|
||||
|
||||
self.services = CheckboxList(
|
||||
frame, text="Services", clicked=self.service_clicked
|
||||
frame, self.app, text="Services", clicked=self.service_clicked
|
||||
)
|
||||
self.services.grid(row=0, column=1, sticky="nsew")
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ class EmaneConfiguration(Dialog):
|
|||
self.emane_dialog.top.columnconfigure(0, weight=1)
|
||||
self.emane_dialog.top.rowconfigure(0, weight=1)
|
||||
self.emane_config_frame = ConfigFrame(
|
||||
self.emane_dialog.top, config=self.options
|
||||
self.emane_dialog.top, self.app, config=self.options
|
||||
)
|
||||
self.emane_config_frame.draw_config()
|
||||
self.emane_config_frame.grid(sticky="nsew")
|
||||
|
@ -167,7 +167,7 @@ class EmaneConfiguration(Dialog):
|
|||
|
||||
self.model_options = response.config
|
||||
self.model_config_frame = ConfigFrame(
|
||||
self.emane_model_dialog.top, config=self.model_options
|
||||
self.emane_model_dialog.top, self.app, config=self.model_options
|
||||
)
|
||||
self.model_config_frame.grid(sticky="nsew")
|
||||
self.model_config_frame.draw_config()
|
||||
|
|
|
@ -38,7 +38,7 @@ class NodeService(Dialog):
|
|||
self.groups.listbox.selection_set(0)
|
||||
|
||||
self.services = CheckboxList(
|
||||
frame, text="Services", clicked=self.service_clicked
|
||||
frame, self.app, text="Services", clicked=self.service_clicked
|
||||
)
|
||||
self.services.grid(row=0, column=1, sticky="nsew")
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class SessionOptionsDialog(Dialog):
|
|||
response = self.app.core.client.get_session_options(session_id)
|
||||
logging.info("session options: %s", response)
|
||||
|
||||
self.config_frame = ConfigFrame(self.top, config=response.config)
|
||||
self.config_frame = ConfigFrame(self.top, self.app, config=response.config)
|
||||
self.config_frame.draw_config()
|
||||
self.config_frame.grid(sticky="nsew")
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import logging
|
||||
import tkinter as tk
|
||||
|
||||
DARK = "black"
|
||||
|
@ -118,9 +119,8 @@ def load(style):
|
|||
)
|
||||
|
||||
|
||||
def update_toplevel(style, event):
|
||||
if not isinstance(event.widget, tk.Toplevel):
|
||||
return
|
||||
def update_bg(style, event):
|
||||
logging.info("updating background: %s", event.widget)
|
||||
bg = style.lookup(".", "background")
|
||||
event.widget.config(background=bg)
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ from functools import partial
|
|||
from tkinter import ttk
|
||||
|
||||
from core.api.grpc import core_pb2
|
||||
from coretk.themes import Styles
|
||||
|
||||
INT_TYPES = {
|
||||
core_pb2.ConfigOptionType.UINT8,
|
||||
|
@ -19,11 +18,13 @@ INT_TYPES = {
|
|||
|
||||
|
||||
class FrameScroll(ttk.LabelFrame):
|
||||
def __init__(self, master=None, _cls=tk.Frame, **kw):
|
||||
def __init__(self, master, app, _cls=ttk.Frame, **kw):
|
||||
super().__init__(master, **kw)
|
||||
self.app = app
|
||||
self.rowconfigure(0, weight=1)
|
||||
self.columnconfigure(0, weight=1)
|
||||
self.canvas = tk.Canvas(self, highlightthickness=0)
|
||||
bg = self.app.style.lookup(".", "background")
|
||||
self.canvas = tk.Canvas(self, highlightthickness=0, background=bg)
|
||||
self.canvas.grid(row=0, sticky="nsew", padx=2, pady=2)
|
||||
self.canvas.columnconfigure(0, weight=1)
|
||||
self.canvas.rowconfigure(0, weight=1)
|
||||
|
@ -55,8 +56,8 @@ class FrameScroll(ttk.LabelFrame):
|
|||
|
||||
|
||||
class ConfigFrame(FrameScroll):
|
||||
def __init__(self, master=None, config=None, **kw):
|
||||
super().__init__(master, ttk.Notebook, **kw)
|
||||
def __init__(self, master, app, config, **kw):
|
||||
super().__init__(master, app, ttk.Notebook, **kw)
|
||||
self.config = config
|
||||
self.values = {}
|
||||
|
||||
|
@ -143,19 +144,13 @@ class ListboxScroll(ttk.LabelFrame):
|
|||
|
||||
|
||||
class CheckboxList(FrameScroll):
|
||||
def __init__(self, master=None, clicked=None, **kw):
|
||||
super().__init__(master, **kw)
|
||||
def __init__(self, master, app, clicked=None, **kw):
|
||||
super().__init__(master, app, **kw)
|
||||
self.clicked = clicked
|
||||
self.frame.columnconfigure(0, weight=1)
|
||||
|
||||
def add(self, name, checked):
|
||||
var = tk.BooleanVar(value=checked)
|
||||
func = partial(self.clicked, name, var)
|
||||
checkbox = ttk.Checkbutton(
|
||||
self.frame,
|
||||
text=name,
|
||||
variable=var,
|
||||
command=func,
|
||||
style=Styles.service_checkbutton,
|
||||
)
|
||||
checkbox = ttk.Checkbutton(self.frame, text=name, variable=var, command=func)
|
||||
checkbox.grid(sticky="w")
|
||||
|
|
Loading…
Add table
Reference in a new issue