From c4f21e8a2ee12f7797594715f910b3721e16eb8a Mon Sep 17 00:00:00 2001 From: Blake Harnden <32446120+bharnden@users.noreply.github.com> Date: Mon, 16 Dec 2019 14:17:05 -0800 Subject: [PATCH] cleaned up listboxscroll widgets to not default to a labeleframe, updated code that really needed a lebelframe --- coretk/coretk/dialogs/customnodes.py | 22 ++++++++++----- coretk/coretk/dialogs/nodeservice.py | 16 ++++++++--- coretk/coretk/dialogs/serviceconfiguration.py | 28 ++++++++++++------- coretk/coretk/widgets.py | 2 +- 4 files changed, 46 insertions(+), 22 deletions(-) diff --git a/coretk/coretk/dialogs/customnodes.py b/coretk/coretk/dialogs/customnodes.py index 6aabf417..7effd11a 100644 --- a/coretk/coretk/dialogs/customnodes.py +++ b/coretk/coretk/dialogs/customnodes.py @@ -24,13 +24,17 @@ class ServicesSelectDialog(Dialog): self.top.columnconfigure(0, weight=1) self.top.rowconfigure(0, weight=1) - frame = ttk.Frame(self.top) + frame = ttk.LabelFrame(self.top) frame.grid(stick="nsew", pady=PADY) frame.rowconfigure(0, weight=1) for i in range(3): frame.columnconfigure(i, weight=1) - self.groups = ListboxScroll(frame, text="Groups", padding=FRAME_PAD) - self.groups.grid(row=0, column=0, sticky="nsew") + label_frame = ttk.LabelFrame(frame, text="Groups", padding=FRAME_PAD) + label_frame.grid(row=0, column=0, sticky="nsew") + label_frame.rowconfigure(0, weight=1) + label_frame.columnconfigure(0, weight=1) + self.groups = ListboxScroll(label_frame) + self.groups.grid(sticky="nsew") for group in sorted(self.app.core.services): self.groups.listbox.insert(tk.END, group) self.groups.listbox.bind("<>", self.handle_group_change) @@ -45,8 +49,12 @@ class ServicesSelectDialog(Dialog): ) self.services.grid(row=0, column=1, sticky="nsew") - self.current = ListboxScroll(frame, text="Selected", padding=FRAME_PAD) - self.current.grid(row=0, column=2, sticky="nsew") + label_frame = ttk.LabelFrame(frame, text="Selected", padding=FRAME_PAD) + label_frame.grid(row=0, column=2, sticky="nsew") + label_frame.rowconfigure(0, weight=1) + label_frame.columnconfigure(0, weight=1) + self.current = ListboxScroll(label_frame) + self.current.grid(sticky="nsew") for service in sorted(self.current_services): self.current.listbox.insert(tk.END, service) @@ -109,12 +117,12 @@ class CustomNodesDialog(Dialog): self.draw_buttons() def draw_node_config(self): - frame = ttk.Frame(self.top) + frame = ttk.LabelFrame(self.top, text="Nodes", padding=FRAME_PAD) frame.grid(sticky="nsew", pady=PADY) frame.columnconfigure(0, weight=1) frame.rowconfigure(0, weight=1) - self.nodes_list = ListboxScroll(frame, text="Nodes", padding=FRAME_PAD) + self.nodes_list = ListboxScroll(frame) self.nodes_list.grid(row=0, column=0, sticky="nsew", padx=PADX) self.nodes_list.listbox.bind("<>", self.handle_node_select) for name in sorted(self.app.core.custom_nodes): diff --git a/coretk/coretk/dialogs/nodeservice.py b/coretk/coretk/dialogs/nodeservice.py index 2aa9c6ad..59b8865b 100644 --- a/coretk/coretk/dialogs/nodeservice.py +++ b/coretk/coretk/dialogs/nodeservice.py @@ -40,8 +40,12 @@ class NodeService(Dialog): frame.rowconfigure(0, weight=1) for i in range(3): frame.columnconfigure(i, weight=1) - self.groups = ListboxScroll(frame, text="Groups", padding=FRAME_PAD) - self.groups.grid(row=0, column=0, sticky="nsew") + label_frame = ttk.LabelFrame(frame, text="Groups", padding=FRAME_PAD) + label_frame.grid(row=0, column=0, sticky="nsew") + label_frame.rowconfigure(0, weight=1) + label_frame.columnconfigure(0, weight=1) + self.groups = ListboxScroll(label_frame) + self.groups.grid(sticky="nsew") for group in sorted(self.app.core.services): self.groups.listbox.insert(tk.END, group) self.groups.listbox.bind("<>", self.handle_group_change) @@ -56,8 +60,12 @@ class NodeService(Dialog): ) self.services.grid(row=0, column=1, sticky="nsew") - self.current = ListboxScroll(frame, text="Selected", padding=FRAME_PAD) - self.current.grid(row=0, column=2, sticky="nsew") + label_frame = ttk.LabelFrame(frame, text="Selected", padding=FRAME_PAD) + label_frame.grid(row=0, column=2, sticky="nsew") + label_frame.rowconfigure(0, weight=1) + label_frame.columnconfigure(0, weight=1) + self.current = ListboxScroll(label_frame) + self.current.grid(sticky="nsew") for service in sorted(self.current_services): self.current.listbox.insert(tk.END, service) diff --git a/coretk/coretk/dialogs/serviceconfiguration.py b/coretk/coretk/dialogs/serviceconfiguration.py index a53c2aa1..0031ee31 100644 --- a/coretk/coretk/dialogs/serviceconfiguration.py +++ b/coretk/coretk/dialogs/serviceconfiguration.py @@ -216,32 +216,32 @@ class ServiceConfiguration(Dialog): tab.columnconfigure(0, weight=1) for i in range(3): tab.rowconfigure(i, weight=1) - self.notebook.add(tab, text="Startup/shutdown") + self.notebook.add(tab, text="Startup/Shutdown") # tab 3 for i in range(3): label_frame = None if i == 0: label_frame = ttk.LabelFrame( - tab, text="Startup commands", padding=FRAME_PAD + tab, text="Startup Commands", padding=FRAME_PAD ) commands = self.startup_commands elif i == 1: label_frame = ttk.LabelFrame( - tab, text="Shutdown commands", padding=FRAME_PAD + tab, text="Shutdown Commands", padding=FRAME_PAD ) commands = self.shutdown_commands elif i == 2: label_frame = ttk.LabelFrame( - tab, text="Validation commands", padding=FRAME_PAD + tab, text="Validation Commands", padding=FRAME_PAD ) commands = self.validation_commands label_frame.columnconfigure(0, weight=1) label_frame.rowconfigure(1, weight=1) - label_frame.grid(row=i, column=0, sticky="nsew") + label_frame.grid(row=i, column=0, sticky="nsew", pady=PADY) frame = ttk.Frame(label_frame) - frame.grid(row=0, column=0, sticky="nsew") + frame.grid(row=0, column=0, sticky="nsew", pady=PADY) frame.columnconfigure(0, weight=1) entry = ttk.Entry(frame, textvariable=tk.StringVar()) entry.grid(row=0, column=0, stick="ew", padx=PADX) @@ -251,7 +251,7 @@ class ServiceConfiguration(Dialog): button = ttk.Button(frame, image=self.editdelete_img) button.grid(row=0, column=2, sticky="ew") button.bind("", self.delete_command) - listbox_scroll = ListboxScroll(label_frame, borderwidth=0) + listbox_scroll = ListboxScroll(label_frame) listbox_scroll.listbox.bind("<>", self.update_entry) for command in commands: listbox_scroll.listbox.insert("end", command) @@ -303,13 +303,21 @@ class ServiceConfiguration(Dialog): ) self.validation_period_entry.grid(row=2, column=1, sticky="ew") - listbox_scroll = ListboxScroll(tab, text="Executables", padding=FRAME_PAD) - listbox_scroll.grid(sticky="nsew", pady=PADY) + label_frame = ttk.LabelFrame(tab, text="Executables", padding=FRAME_PAD) + label_frame.grid(sticky="nsew", pady=PADY) + label_frame.columnconfigure(0, weight=1) + label_frame.rowconfigure(0, weight=1) + listbox_scroll = ListboxScroll(label_frame) + listbox_scroll.grid(sticky="nsew") tab.rowconfigure(listbox_scroll.grid_info()["row"], weight=1) for executable in self.executables: listbox_scroll.listbox.insert("end", executable) - listbox_scroll = ListboxScroll(tab, text="Dependencies", padding=FRAME_PAD) + label_frame = ttk.LabelFrame(tab, text="Dependencies", padding=FRAME_PAD) + label_frame.grid(sticky="nsew", pady=PADY) + label_frame.columnconfigure(0, weight=1) + label_frame.rowconfigure(0, weight=1) + listbox_scroll = ListboxScroll(label_frame) listbox_scroll.grid(sticky="nsew") tab.rowconfigure(listbox_scroll.grid_info()["row"], weight=1) for dependency in self.dependencies: diff --git a/coretk/coretk/widgets.py b/coretk/coretk/widgets.py index a00b590a..feed7958 100644 --- a/coretk/coretk/widgets.py +++ b/coretk/coretk/widgets.py @@ -175,7 +175,7 @@ class ConfigFrame(FrameScroll): return {x: self.config[x].value for x in self.config} -class ListboxScroll(ttk.LabelFrame): +class ListboxScroll(ttk.Frame): def __init__(self, master=None, **kw): super().__init__(master, **kw) self.columnconfigure(0, weight=1)