From 8585911900ddef76de0e9fa6df0940c200e9eac4 Mon Sep 17 00:00:00 2001 From: Blake Harnden <32446120+bharnden@users.noreply.github.com> Date: Wed, 11 Dec 2019 11:42:05 -0800 Subject: [PATCH 1/3] updated theme and size for picker buttons, also added text for clarity --- coretk/coretk/app.py | 2 ++ coretk/coretk/dialogs/dialog.py | 1 - coretk/coretk/nodeutils.py | 39 ++++++++++++++++----------------- coretk/coretk/themes.py | 5 +++++ coretk/coretk/toolbar.py | 31 ++++++++++++++++---------- 5 files changed, 45 insertions(+), 33 deletions(-) diff --git a/coretk/coretk/app.py b/coretk/coretk/app.py index c2eeadc3..0a9275f1 100644 --- a/coretk/coretk/app.py +++ b/coretk/coretk/app.py @@ -42,6 +42,8 @@ class Application(tk.Frame): self.style.theme_use(self.guiconfig["preferences"]["theme"]) func = partial(themes.update_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/dialogs/dialog.py b/coretk/coretk/dialogs/dialog.py index d814a47c..29362960 100644 --- a/coretk/coretk/dialogs/dialog.py +++ b/coretk/coretk/dialogs/dialog.py @@ -9,7 +9,6 @@ DIALOG_PAD = 5 class Dialog(tk.Toplevel): def __init__(self, master, app, title, modal=False): super().__init__(master) - self.geometry("800x600") self.withdraw() self.app = app self.modal = modal diff --git a/coretk/coretk/nodeutils.py b/coretk/coretk/nodeutils.py index 10d926f7..cb0bc7a3 100644 --- a/coretk/coretk/nodeutils.py +++ b/coretk/coretk/nodeutils.py @@ -13,18 +13,16 @@ class NodeDraw: self.image_file = None self.node_type = None self.model = None - self.tooltip = None self.services = set() @classmethod - def from_setup(cls, image_enum, node_type, model=None, tooltip=None): + def from_setup(cls, image_enum, node_type, label, model=None, tooltip=None): node_draw = NodeDraw() node_draw.image_enum = image_enum node_draw.image = Images.get(image_enum, ICON_SIZE) node_draw.node_type = node_type + node_draw.label = label node_draw.model = model - if tooltip is None: - tooltip = model node_draw.tooltip = tooltip return node_draw @@ -36,6 +34,7 @@ class NodeDraw: node_draw.image = Images.get_custom(image_file, ICON_SIZE) node_draw.node_type = NodeType.DEFAULT node_draw.services = services + node_draw.label = name node_draw.model = name node_draw.tooltip = name return node_draw @@ -81,29 +80,29 @@ class NodeUtils: @classmethod def setup(cls): nodes = [ - (ImageEnum.ROUTER, NodeType.DEFAULT, "router"), - (ImageEnum.HOST, NodeType.DEFAULT, "host"), - (ImageEnum.PC, NodeType.DEFAULT, "PC"), - (ImageEnum.MDR, NodeType.DEFAULT, "mdr"), - (ImageEnum.PROUTER, NodeType.DEFAULT, "prouter"), - (ImageEnum.DOCKER, NodeType.DOCKER, "Docker"), - (ImageEnum.LXC, NodeType.LXC, "LXC"), + (ImageEnum.ROUTER, NodeType.DEFAULT, "Router", "router"), + (ImageEnum.HOST, NodeType.DEFAULT, "Host", "host"), + (ImageEnum.PC, NodeType.DEFAULT, "PC", "PC"), + (ImageEnum.MDR, NodeType.DEFAULT, "MDR", "mdr"), + (ImageEnum.PROUTER, NodeType.DEFAULT, "PRouter", "prouter"), + (ImageEnum.DOCKER, NodeType.DOCKER, "Docker", None), + (ImageEnum.LXC, NodeType.LXC, "LXC", None), ] - for image_enum, node_type, model in nodes: - node_draw = NodeDraw.from_setup(image_enum, node_type, model) + for image_enum, node_type, label, model in nodes: + node_draw = NodeDraw.from_setup(image_enum, node_type, label, model) cls.NODES.append(node_draw) cls.NODE_ICONS[(node_type, model)] = node_draw.image network_nodes = [ - (ImageEnum.HUB, NodeType.HUB, "ethernet hub"), - (ImageEnum.SWITCH, NodeType.SWITCH, "ethernet switch"), - (ImageEnum.WLAN, NodeType.WIRELESS_LAN, "wireless LAN"), + (ImageEnum.HUB, NodeType.HUB, "Hub"), + (ImageEnum.SWITCH, NodeType.SWITCH, "Switch"), + (ImageEnum.WLAN, NodeType.WIRELESS_LAN, "WLAN"), (ImageEnum.EMANE, NodeType.EMANE, "EMANE"), - (ImageEnum.RJ45, NodeType.RJ45, "rj45 physical interface tool"), - (ImageEnum.TUNNEL, NodeType.TUNNEL, "tunnel tool"), + (ImageEnum.RJ45, NodeType.RJ45, "RJ45"), + (ImageEnum.TUNNEL, NodeType.TUNNEL, "Tunnel"), ] - for image_enum, node_type, tooltip in network_nodes: - node_draw = NodeDraw.from_setup(image_enum, node_type, tooltip=tooltip) + for image_enum, node_type, label in network_nodes: + node_draw = NodeDraw.from_setup(image_enum, node_type, label) cls.NETWORK_NODES.append(node_draw) cls.NODE_ICONS[(node_type, None)] = node_draw.image cls.ANTENNA_ICON = Images.get(ImageEnum.ANTENNA, ANTENNA_SIZE) diff --git a/coretk/coretk/themes.py b/coretk/coretk/themes.py index b80caf87..a1982b3e 100644 --- a/coretk/coretk/themes.py +++ b/coretk/coretk/themes.py @@ -8,6 +8,7 @@ class Styles: tooltip = "Tooltip.TLabel" tooltip_frame = "Tooltip.TFrame" service_checkbutton = "Service.TCheckbutton" + picker_button = "Picker.TButton" class Colors: @@ -150,3 +151,7 @@ def update_menu(style, event): event.widget.config( background=bg, foreground=fg, activebackground=abg, activeforeground=fg ) + + +def theme_change(style, event): + style.configure(Styles.picker_button, font=("TkDefaultFont", 8, "normal")) diff --git a/coretk/coretk/toolbar.py b/coretk/coretk/toolbar.py index a47cac5e..72288b71 100644 --- a/coretk/coretk/toolbar.py +++ b/coretk/coretk/toolbar.py @@ -3,6 +3,7 @@ import threading import tkinter as tk from functools import partial from tkinter import ttk +from tkinter.font import Font from coretk.dialogs.customnodes import CustomNodesDialog from coretk.graph import tags @@ -10,13 +11,15 @@ from coretk.graph.enums import GraphMode from coretk.graph.shapeutils import ShapeType from coretk.images import ImageEnum, Images from coretk.nodeutils import NodeUtils +from coretk.themes import Styles from coretk.tooltip import Tooltip WIDTH = 32 +PICKER_SIZE = 24 -def icon(image_enum): - return Images.get(image_enum, WIDTH) +def icon(image_enum, width=WIDTH): + return Images.get(image_enum, width) class Toolbar(ttk.Frame): @@ -34,6 +37,9 @@ class Toolbar(ttk.Frame): self.app = app self.master = app.master + # picker data + self.picker_font = Font(size=8) + # design buttons self.select_button = None self.link_button = None @@ -140,9 +146,9 @@ class Toolbar(ttk.Frame): self.node_picker = ttk.Frame(self.master) # draw default nodes for node_draw in NodeUtils.NODES: - image = icon(node_draw.image_enum) + image = icon(node_draw.image_enum, PICKER_SIZE) func = partial(self.update_button, self.node_button, image, node_draw) - self.create_picker_button(image, func, self.node_picker, node_draw.tooltip) + self.create_picker_button(image, func, self.node_picker, node_draw.label) # draw custom nodes for name in sorted(self.app.core.custom_nodes): node_draw = self.app.core.custom_nodes[name] @@ -152,7 +158,7 @@ class Toolbar(ttk.Frame): # draw edit node image = icon(ImageEnum.EDITNODE) self.create_picker_button( - image, self.click_edit_node, self.node_picker, "custom nodes" + image, self.click_edit_node, self.node_picker, "Custom" ) self.design_select(self.node_button) self.node_button.after( @@ -169,21 +175,22 @@ class Toolbar(ttk.Frame): self.wait_window(picker) self.app.unbind_all("") - def create_picker_button(self, image, func, frame, tooltip): + def create_picker_button(self, image, func, frame, label): """ Create button and put it on the frame :param PIL.Image image: button image :param func: the command that is executed when button is clicked :param tkinter.Frame frame: frame that contains the button - :param str tooltip: tooltip text + :param str label: button label :return: nothing """ - button = ttk.Button(frame, image=image) + button = ttk.Button( + frame, image=image, text=label, compound=tk.TOP, style=Styles.picker_button + ) button.image = image button.bind("", lambda e: func()) button.grid(pady=1) - Tooltip(button, tooltip) def create_button(self, frame, image, func, tooltip): button = ttk.Button(frame, image=image, command=func) @@ -269,12 +276,12 @@ class Toolbar(ttk.Frame): self.hide_pickers() self.network_picker = ttk.Frame(self.master) for node_draw in NodeUtils.NETWORK_NODES: - image = icon(node_draw.image_enum) + image = icon(node_draw.image_enum, PICKER_SIZE) self.create_picker_button( image, partial(self.update_button, self.network_button, image, node_draw), self.network_picker, - node_draw.tooltip, + node_draw.label, ) self.design_select(self.network_button) self.network_button.after( @@ -311,7 +318,7 @@ class Toolbar(ttk.Frame): (ImageEnum.TEXT, ShapeType.TEXT), ] for image_enum, shape_type in nodes: - image = icon(image_enum) + image = icon(image_enum, PICKER_SIZE) self.create_picker_button( image, partial(self.update_annotation, image, shape_type), From 69296d6ea9a3f1efcbccc1c63b4d75661b17301a Mon Sep 17 00:00:00 2001 From: Blake Harnden <32446120+bharnden@users.noreply.github.com> Date: Wed, 11 Dec 2019 14:09:50 -0800 Subject: [PATCH 2/3] pass on updating dialogs to have buttons float to bottom and start using common pad configuration --- coretk/coretk/app.py | 13 +- coretk/coretk/dialogs/canvassizeandscale.py | 1 + ...canvasbackground.py => canvaswallpaper.py} | 23 ++-- coretk/coretk/dialogs/customnodes.py | 26 ++-- coretk/coretk/dialogs/dialog.py | 6 + coretk/coretk/dialogs/emaneconfig.py | 12 +- coretk/coretk/dialogs/hooks.py | 34 ++--- coretk/coretk/dialogs/icondialog.py | 17 ++- coretk/coretk/dialogs/mobilityconfig.py | 3 +- coretk/coretk/dialogs/mobilityplayer.py | 1 + coretk/coretk/dialogs/nodeconfig.py | 27 ++-- coretk/coretk/dialogs/nodeservice.py | 12 +- coretk/coretk/dialogs/observers.py | 12 +- coretk/coretk/dialogs/preferences.py | 15 ++- coretk/coretk/dialogs/servers.py | 26 ++-- coretk/coretk/dialogs/sessions.py | 26 ++-- coretk/coretk/dialogs/shapemod.py | 126 +++++++++--------- coretk/coretk/dialogs/wlanconfig.py | 3 +- coretk/coretk/graph/node.py | 2 + coretk/coretk/menuaction.py | 2 +- coretk/coretk/menubar.py | 16 +-- coretk/coretk/themes.py | 8 +- coretk/coretk/widgets.py | 2 +- 23 files changed, 223 insertions(+), 190 deletions(-) rename coretk/coretk/dialogs/{canvasbackground.py => canvaswallpaper.py} (90%) diff --git a/coretk/coretk/app.py b/coretk/coretk/app.py index 0a9275f1..7c2562a9 100644 --- a/coretk/coretk/app.py +++ b/coretk/coretk/app.py @@ -14,6 +14,9 @@ from coretk.statusbar import StatusBar from coretk.toolbar import Toolbar from coretk.validation import InputValidation +WIDTH = 1000 +HEIGHT = 800 + class Application(tk.Frame): def __init__(self, master=None): @@ -40,7 +43,7 @@ class Application(tk.Frame): def setup_theme(self): themes.load(self.style) self.style.theme_use(self.guiconfig["preferences"]["theme"]) - func = partial(themes.update_menu, self.style) + 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) @@ -55,13 +58,11 @@ class Application(tk.Frame): self.validation = InputValidation(self) def center(self): - width = 1000 - height = 800 screen_width = self.master.winfo_screenwidth() screen_height = self.master.winfo_screenheight() - x = int((screen_width / 2) - (width / 2)) - y = int((screen_height / 2) - (height / 2)) - self.master.geometry(f"{width}x{height}+{x}+{y}") + x = int((screen_width / 2) - (WIDTH / 2)) + y = int((screen_height / 2) - (HEIGHT / 2)) + self.master.geometry(f"{WIDTH}x{HEIGHT}+{x}+{y}") def draw(self): self.master.option_add("*tearOff", tk.FALSE) diff --git a/coretk/coretk/dialogs/canvassizeandscale.py b/coretk/coretk/dialogs/canvassizeandscale.py index 2798f6f2..1fcfff59 100644 --- a/coretk/coretk/dialogs/canvassizeandscale.py +++ b/coretk/coretk/dialogs/canvassizeandscale.py @@ -46,6 +46,7 @@ class SizeAndScaleDialog(Dialog): self.draw_scale() self.draw_reference_point() self.draw_save_as_default() + self.draw_spacer() self.draw_buttons() def draw_size(self): diff --git a/coretk/coretk/dialogs/canvasbackground.py b/coretk/coretk/dialogs/canvaswallpaper.py similarity index 90% rename from coretk/coretk/dialogs/canvasbackground.py rename to coretk/coretk/dialogs/canvaswallpaper.py index 844b5595..bf6bf922 100644 --- a/coretk/coretk/dialogs/canvasbackground.py +++ b/coretk/coretk/dialogs/canvaswallpaper.py @@ -9,7 +9,7 @@ from coretk.appconfig import BACKGROUNDS_PATH from coretk.dialogs.dialog import Dialog from coretk.images import Images -PADX = 5 +PAD = 5 class CanvasBackgroundDialog(Dialog): @@ -36,17 +36,18 @@ class CanvasBackgroundDialog(Dialog): self.draw_image_selection() self.draw_options() self.draw_additional_options() + self.draw_spacer() self.draw_buttons() def draw_image(self): self.image_label = ttk.Label( self.top, text="(image preview)", width=32, anchor=tk.CENTER ) - self.image_label.grid(row=0, column=0, pady=5) + self.image_label.grid(pady=PAD) def draw_image_label(self): label = ttk.Label(self.top, text="Image filename: ") - label.grid(row=1, column=0, sticky="ew") + label.grid(sticky="ew") if self.filename.get(): self.draw_preview() @@ -55,14 +56,14 @@ class CanvasBackgroundDialog(Dialog): frame.columnconfigure(0, weight=2) frame.columnconfigure(1, weight=1) frame.columnconfigure(2, weight=1) - frame.grid(row=2, column=0, sticky="ew") + frame.grid(sticky="ew") entry = ttk.Entry(frame, textvariable=self.filename) entry.focus() - entry.grid(row=0, column=0, sticky="ew", padx=PADX) + entry.grid(row=0, column=0, sticky="ew", padx=PAD) button = ttk.Button(frame, text="...", command=self.click_open_image) - button.grid(row=0, column=1, sticky="ew", padx=PADX) + button.grid(row=0, column=1, sticky="ew", padx=PAD) button = ttk.Button(frame, text="Clear", command=self.click_clear) button.grid(row=0, column=2, sticky="ew") @@ -73,7 +74,7 @@ class CanvasBackgroundDialog(Dialog): frame.columnconfigure(1, weight=1) frame.columnconfigure(2, weight=1) frame.columnconfigure(3, weight=1) - frame.grid(row=3, column=0, sticky="ew") + frame.grid(sticky="ew") button = ttk.Radiobutton( frame, text="upper-left", value=1, variable=self.scale_option @@ -103,7 +104,7 @@ class CanvasBackgroundDialog(Dialog): checkbutton = ttk.Checkbutton( self.top, text="Show grid", variable=self.show_grid ) - checkbutton.grid(row=4, column=0, sticky="ew", padx=PADX) + checkbutton.grid(sticky="ew", padx=PAD) checkbutton = ttk.Checkbutton( self.top, @@ -111,16 +112,16 @@ class CanvasBackgroundDialog(Dialog): variable=self.adjust_to_dim, command=self.click_adjust_canvas, ) - checkbutton.grid(row=5, column=0, sticky="ew", padx=PADX) + checkbutton.grid(sticky="ew", padx=PAD) def draw_buttons(self): frame = ttk.Frame(self.top) - frame.grid(row=6, column=0, pady=5, sticky="ew") + frame.grid(pady=PAD, sticky="ew") frame.columnconfigure(0, weight=1) frame.columnconfigure(1, weight=1) button = ttk.Button(frame, text="Apply", command=self.click_apply) - button.grid(row=0, column=0, sticky="ew", padx=PADX) + button.grid(row=0, column=0, sticky="ew", padx=PAD) button = ttk.Button(frame, text="Cancel", command=self.destroy) button.grid(row=0, column=1, sticky="ew") diff --git a/coretk/coretk/dialogs/customnodes.py b/coretk/coretk/dialogs/customnodes.py index dbf431d3..75052e6b 100644 --- a/coretk/coretk/dialogs/customnodes.py +++ b/coretk/coretk/dialogs/customnodes.py @@ -8,6 +8,8 @@ from coretk.dialogs.icondialog import IconDialog from coretk.nodeutils import NodeDraw from coretk.widgets import CheckboxList, ListboxScroll +PAD = 5 + class ServicesSelectDialog(Dialog): def __init__(self, master, app, current_services): @@ -23,11 +25,11 @@ class ServicesSelectDialog(Dialog): self.top.rowconfigure(0, weight=1) frame = ttk.Frame(self.top) - frame.grid(stick="nsew") + frame.grid(stick="nsew", pady=PAD) frame.rowconfigure(0, weight=1) for i in range(3): frame.columnconfigure(i, weight=1) - self.groups = ListboxScroll(frame, text="Groups") + self.groups = ListboxScroll(frame, text="Groups", padding=PAD) self.groups.grid(row=0, column=0, sticky="nsew") for group in sorted(self.app.core.services): self.groups.listbox.insert(tk.END, group) @@ -35,11 +37,11 @@ class ServicesSelectDialog(Dialog): self.groups.listbox.selection_set(0) self.services = CheckboxList( - frame, self.app, text="Services", clicked=self.service_clicked + frame, self.app, text="Services", clicked=self.service_clicked, padding=PAD ) self.services.grid(row=0, column=1, sticky="nsew") - self.current = ListboxScroll(frame, text="Selected") + self.current = ListboxScroll(frame, text="Selected", padding=PAD) self.current.grid(row=0, column=2, sticky="nsew") for service in sorted(self.current_services): self.current.listbox.insert(tk.END, service) @@ -49,7 +51,7 @@ class ServicesSelectDialog(Dialog): for i in range(2): frame.columnconfigure(i, weight=1) button = ttk.Button(frame, text="Save", command=self.destroy) - button.grid(row=0, column=0, sticky="ew") + button.grid(row=0, column=0, sticky="ew", padx=PAD) button = ttk.Button(frame, text="Cancel", command=self.click_cancel) button.grid(row=0, column=1, sticky="ew") @@ -104,12 +106,12 @@ class CustomNodesDialog(Dialog): def draw_node_config(self): frame = ttk.Frame(self.top) - frame.grid(sticky="nsew") + frame.grid(sticky="nsew", pady=PAD) frame.columnconfigure(0, weight=1) frame.rowconfigure(0, weight=1) - self.nodes_list = ListboxScroll(frame, text="Nodes") - self.nodes_list.grid(row=0, column=0, sticky="nsew") + self.nodes_list = ListboxScroll(frame, text="Nodes", padding=PAD) + self.nodes_list.grid(row=0, column=0, sticky="nsew", padx=PAD) self.nodes_list.listbox.bind("<>", self.handle_node_select) for name in sorted(self.app.core.custom_nodes): self.nodes_list.listbox.insert(tk.END, name) @@ -128,17 +130,17 @@ class CustomNodesDialog(Dialog): def draw_node_buttons(self): frame = ttk.Frame(self.top) - frame.grid(pady=2, sticky="ew") + frame.grid(sticky="ew", pady=PAD) for i in range(3): frame.columnconfigure(i, weight=1) button = ttk.Button(frame, text="Create", command=self.click_create) - button.grid(row=0, column=0, sticky="ew") + button.grid(row=0, column=0, sticky="ew", padx=PAD) self.edit_button = ttk.Button( frame, text="Edit", state=tk.DISABLED, command=self.click_edit ) - self.edit_button.grid(row=0, column=1, sticky="ew") + self.edit_button.grid(row=0, column=1, sticky="ew", padx=PAD) self.delete_button = ttk.Button( frame, text="Delete", state=tk.DISABLED, command=self.click_delete @@ -152,7 +154,7 @@ class CustomNodesDialog(Dialog): frame.columnconfigure(i, weight=1) button = ttk.Button(frame, text="Save", command=self.click_save) - button.grid(row=0, column=0, sticky="ew") + button.grid(row=0, column=0, sticky="ew", padx=PAD) button = ttk.Button(frame, text="Cancel", command=self.destroy) button.grid(row=0, column=1, sticky="ew") diff --git a/coretk/coretk/dialogs/dialog.py b/coretk/coretk/dialogs/dialog.py index 29362960..49662cc4 100644 --- a/coretk/coretk/dialogs/dialog.py +++ b/coretk/coretk/dialogs/dialog.py @@ -30,3 +30,9 @@ class Dialog(tk.Toplevel): self.wait_visibility() self.grab_set() self.wait_window() + + def draw_spacer(self, row=None): + frame = ttk.Frame(self.top) + frame.grid(row=row, sticky="nsew") + frame.rowconfigure(0, weight=1) + self.top.rowconfigure(frame.grid_info()["row"], weight=1) diff --git a/coretk/coretk/dialogs/emaneconfig.py b/coretk/coretk/dialogs/emaneconfig.py index a9042ba3..b16f7cd4 100644 --- a/coretk/coretk/dialogs/emaneconfig.py +++ b/coretk/coretk/dialogs/emaneconfig.py @@ -25,11 +25,10 @@ class GlobalEmaneDialog(Dialog): def draw(self): self.top.columnconfigure(0, weight=1) self.top.rowconfigure(0, weight=1) - self.config_frame = ConfigFrame( - self.top, self.app, self.app.core.emane_config, borderwidth=0 - ) + self.config_frame = ConfigFrame(self.top, self.app, self.app.core.emane_config) self.config_frame.draw_config() self.config_frame.grid(sticky="nsew", pady=PAD) + self.draw_spacer() self.draw_buttons() def draw_buttons(self): @@ -67,9 +66,10 @@ class EmaneModelDialog(Dialog): def draw(self): self.top.columnconfigure(0, weight=1) self.top.rowconfigure(0, weight=1) - self.config_frame = ConfigFrame(self.top, self.app, self.config, borderwidth=0) + self.config_frame = ConfigFrame(self.top, self.app, self.config) self.config_frame.draw_config() self.config_frame.grid(sticky="nsew", pady=PAD) + self.draw_spacer() self.draw_buttons() def draw_buttons(self): @@ -111,6 +111,7 @@ class EmaneConfigDialog(Dialog): self.draw_emane_configuration() self.draw_emane_models() self.draw_emane_buttons() + self.draw_spacer() self.draw_apply_and_cancel() def draw_emane_configuration(self): @@ -123,8 +124,9 @@ class EmaneConfigDialog(Dialog): self.top, text="The EMANE emulation system provides more complex wireless radio emulation " "\nusing pluggable MAC and PHY modules. Refer to the wiki for configuration option details", + justify=tk.CENTER, ) - label.grid(sticky="ew", pady=PAD) + label.grid(pady=PAD) image = Images.get(ImageEnum.EDITNODE, 16) button = ttk.Button( diff --git a/coretk/coretk/dialogs/hooks.py b/coretk/coretk/dialogs/hooks.py index d40f1c36..2850d70e 100644 --- a/coretk/coretk/dialogs/hooks.py +++ b/coretk/coretk/dialogs/hooks.py @@ -5,6 +5,8 @@ from core.api.grpc import core_pb2 from coretk.dialogs.dialog import Dialog from coretk.widgets import CodeText +PAD = 5 + class HookDialog(Dialog): def __init__(self, master, app): @@ -21,14 +23,14 @@ class HookDialog(Dialog): # name and states frame = ttk.Frame(self.top) - frame.grid(row=0, sticky="ew", pady=2) + frame.grid(sticky="ew", pady=PAD) frame.columnconfigure(0, weight=2) frame.columnconfigure(1, weight=7) frame.columnconfigure(2, weight=1) label = ttk.Label(frame, text="Name") - label.grid(row=0, column=0, sticky="ew") + label.grid(row=0, column=0, sticky="ew", padx=PAD) entry = ttk.Entry(frame, textvariable=self.name) - entry.grid(row=0, column=1, sticky="ew") + entry.grid(row=0, column=1, sticky="ew", padx=PAD) values = tuple(x for x in core_pb2.SessionState.Enum.keys() if x != "NONE") initial_state = core_pb2.SessionState.Enum.Name(core_pb2.SessionState.RUNTIME) self.state.set(initial_state) @@ -40,11 +42,7 @@ class HookDialog(Dialog): combobox.bind("<>", self.state_change) # data - frame = ttk.Frame(self.top) - frame.columnconfigure(0, weight=1) - frame.rowconfigure(0, weight=1) - frame.grid(row=1, sticky="nsew", pady=2) - self.data = CodeText(frame) + self.data = CodeText(self.top) self.data.insert( 1.0, ( @@ -53,19 +51,15 @@ class HookDialog(Dialog): "# specified state\n" ), ) - self.data.grid(row=0, column=0, sticky="nsew") - scrollbar = ttk.Scrollbar(frame) - scrollbar.grid(row=0, column=1, sticky="ns") - self.data.config(yscrollcommand=scrollbar.set) - scrollbar.config(command=self.data.yview) + self.data.grid(sticky="nsew") # button row frame = ttk.Frame(self.top) - frame.grid(row=2, sticky="ew", pady=2) + frame.grid(sticky="ew") for i in range(2): frame.columnconfigure(i, weight=1) button = ttk.Button(frame, text="Save", command=lambda: self.save()) - button.grid(row=0, column=0, sticky="ew") + button.grid(row=0, column=0, sticky="ew", padx=PAD) button = ttk.Button(frame, text="Cancel", command=lambda: self.destroy()) button.grid(row=0, column=1, sticky="ew") @@ -104,25 +98,25 @@ class HooksDialog(Dialog): self.top.rowconfigure(0, weight=1) self.listbox = tk.Listbox(self.top) - self.listbox.grid(row=0, sticky="nsew") + self.listbox.grid(sticky="nsew", pady=PAD) self.listbox.bind("<>", self.select) for hook_file in self.app.core.hooks: self.listbox.insert(tk.END, hook_file) frame = ttk.Frame(self.top) - frame.grid(row=1, sticky="ew") + frame.grid(sticky="ew") for i in range(4): frame.columnconfigure(i, weight=1) button = ttk.Button(frame, text="Create", command=self.click_create) - button.grid(row=0, column=0, sticky="ew") + button.grid(row=0, column=0, sticky="ew", padx=PAD) self.edit_button = ttk.Button( frame, text="Edit", state=tk.DISABLED, command=self.click_edit ) - self.edit_button.grid(row=0, column=1, sticky="ew") + self.edit_button.grid(row=0, column=1, sticky="ew", padx=PAD) self.delete_button = ttk.Button( frame, text="Delete", state=tk.DISABLED, command=self.click_delete ) - self.delete_button.grid(row=0, column=2, sticky="ew") + self.delete_button.grid(row=0, column=2, sticky="ew", padx=PAD) button = ttk.Button(frame, text="Cancel", command=lambda: self.destroy()) button.grid(row=0, column=3, sticky="ew") diff --git a/coretk/coretk/dialogs/icondialog.py b/coretk/coretk/dialogs/icondialog.py index 98a4ed55..9273a177 100644 --- a/coretk/coretk/dialogs/icondialog.py +++ b/coretk/coretk/dialogs/icondialog.py @@ -6,6 +6,8 @@ from coretk.appconfig import ICONS_PATH from coretk.dialogs.dialog import Dialog from coretk.images import Images +PAD = 5 + class IconDialog(Dialog): def __init__(self, master, app, name, image): @@ -20,27 +22,30 @@ class IconDialog(Dialog): # row one frame = ttk.Frame(self.top) - frame.grid(row=0, column=0, pady=2, sticky="ew") + frame.grid(pady=PAD, sticky="ew") frame.columnconfigure(0, weight=1) frame.columnconfigure(1, weight=3) label = ttk.Label(frame, text="Image") - label.grid(row=0, column=0, sticky="ew") + label.grid(row=0, column=0, sticky="ew", padx=PAD) entry = ttk.Entry(frame, textvariable=self.file_path) - entry.grid(row=0, column=1, sticky="ew") + entry.grid(row=0, column=1, sticky="ew", padx=PAD) button = ttk.Button(frame, text="...", command=self.click_file) button.grid(row=0, column=2) # row two self.image_label = ttk.Label(self.top, image=self.image, anchor=tk.CENTER) - self.image_label.grid(row=1, column=0, pady=2, sticky="ew") + self.image_label.grid(pady=PAD, sticky="ew") + + # spacer + self.draw_spacer() # row three frame = ttk.Frame(self.top) - frame.grid(row=2, column=0, sticky="ew") + frame.grid(sticky="ew") frame.columnconfigure(0, weight=1) frame.columnconfigure(1, weight=1) button = ttk.Button(frame, text="Apply", command=self.destroy) - button.grid(row=0, column=0, sticky="ew") + button.grid(row=0, column=0, sticky="ew", padx=PAD) button = ttk.Button(frame, text="Cancel", command=self.click_cancel) button.grid(row=0, column=1, sticky="ew") diff --git a/coretk/coretk/dialogs/mobilityconfig.py b/coretk/coretk/dialogs/mobilityconfig.py index 4e9d9590..007209dd 100644 --- a/coretk/coretk/dialogs/mobilityconfig.py +++ b/coretk/coretk/dialogs/mobilityconfig.py @@ -32,7 +32,8 @@ class MobilityConfigDialog(Dialog): def draw(self): self.top.columnconfigure(0, weight=1) - self.config_frame = ConfigFrame(self.top, self.app, self.config, borderwidth=0) + self.top.rowconfigure(0, weight=1) + self.config_frame = ConfigFrame(self.top, self.app, self.config) self.config_frame.draw_config() self.config_frame.grid(sticky="nsew", pady=PAD) self.draw_apply_buttons() diff --git a/coretk/coretk/dialogs/mobilityplayer.py b/coretk/coretk/dialogs/mobilityplayer.py index 63698644..1e7b4dc1 100644 --- a/coretk/coretk/dialogs/mobilityplayer.py +++ b/coretk/coretk/dialogs/mobilityplayer.py @@ -61,6 +61,7 @@ class MobilityPlayerDialog(Dialog): super().__init__( master, app, f"{canvas_node.core_node.name} Mobility Player", modal=False ) + self.resizable(False, False) self.geometry("") self.canvas_node = canvas_node self.node = canvas_node.core_node diff --git a/coretk/coretk/dialogs/nodeconfig.py b/coretk/coretk/dialogs/nodeconfig.py index 8853e908..619c5ee7 100644 --- a/coretk/coretk/dialogs/nodeconfig.py +++ b/coretk/coretk/dialogs/nodeconfig.py @@ -66,6 +66,19 @@ class NodeConfigDialog(Dialog): frame.grid(sticky="ew") frame.columnconfigure(1, weight=1) + # icon field + label = ttk.Label(frame, text="Icon") + label.grid(row=row, column=0, sticky="ew", padx=PAD, pady=PAD) + self.image_button = ttk.Button( + frame, + text="Icon", + image=self.image, + compound=tk.NONE, + command=self.click_icon, + ) + self.image_button.grid(row=row, column=1, sticky="ew") + row += 1 + # name field label = ttk.Label(frame, text="Name") label.grid(row=row, column=0, sticky="ew", padx=PAD, pady=PAD) @@ -81,19 +94,6 @@ class NodeConfigDialog(Dialog): entry.grid(row=row, column=1, sticky="ew") row += 1 - # icon field - label = ttk.Label(frame, text="Icon") - label.grid(row=row, column=0, sticky="ew", padx=PAD, pady=PAD) - self.image_button = ttk.Button( - frame, - text="Icon", - image=self.image, - compound=tk.NONE, - command=self.click_icon, - ) - self.image_button.grid(row=row, column=1, sticky="ew") - row += 1 - # node type field if NodeUtils.is_model_node(self.node.type): label = ttk.Label(frame, text="Type") @@ -137,6 +137,7 @@ class NodeConfigDialog(Dialog): if self.canvas_node.interfaces: self.draw_interfaces() + self.draw_spacer() self.draw_buttons() def draw_interfaces(self): diff --git a/coretk/coretk/dialogs/nodeservice.py b/coretk/coretk/dialogs/nodeservice.py index d950371b..dfcef922 100644 --- a/coretk/coretk/dialogs/nodeservice.py +++ b/coretk/coretk/dialogs/nodeservice.py @@ -8,6 +8,8 @@ from coretk.dialogs.dialog import Dialog from coretk.dialogs.serviceconfiguration import ServiceConfiguration from coretk.widgets import CheckboxList, ListboxScroll +PAD = 5 + class NodeService(Dialog): def __init__(self, master, app, canvas_node, services=None): @@ -38,7 +40,7 @@ class NodeService(Dialog): frame.rowconfigure(0, weight=1) for i in range(3): frame.columnconfigure(i, weight=1) - self.groups = ListboxScroll(frame, text="Groups") + self.groups = ListboxScroll(frame, text="Groups", padding=PAD) self.groups.grid(row=0, column=0, sticky="nsew") for group in sorted(self.app.core.services): self.groups.listbox.insert(tk.END, group) @@ -46,11 +48,11 @@ class NodeService(Dialog): self.groups.listbox.selection_set(0) self.services = CheckboxList( - frame, self.app, text="Services", clicked=self.service_clicked + frame, self.app, text="Services", clicked=self.service_clicked, padding=PAD ) self.services.grid(row=0, column=1, sticky="nsew") - self.current = ListboxScroll(frame, text="Selected") + self.current = ListboxScroll(frame, text="Selected", padding=PAD) self.current.grid(row=0, column=2, sticky="nsew") for service in sorted(self.current_services): self.current.listbox.insert(tk.END, service) @@ -60,9 +62,9 @@ class NodeService(Dialog): for i in range(3): frame.columnconfigure(i, weight=1) button = ttk.Button(frame, text="Configure", command=self.click_configure) - button.grid(row=0, column=0, sticky="ew") + button.grid(row=0, column=0, sticky="ew", padx=PAD) button = ttk.Button(frame, text="Save", command=self.click_save) - button.grid(row=0, column=1, sticky="ew") + button.grid(row=0, column=1, sticky="ew", padx=PAD) button = ttk.Button(frame, text="Cancel", command=self.click_cancel) button.grid(row=0, column=2, sticky="ew") diff --git a/coretk/coretk/dialogs/observers.py b/coretk/coretk/dialogs/observers.py index 58499bd7..525939e0 100644 --- a/coretk/coretk/dialogs/observers.py +++ b/coretk/coretk/dialogs/observers.py @@ -4,6 +4,8 @@ from tkinter import ttk from coretk.coreclient import Observer from coretk.dialogs.dialog import Dialog +PAD = 5 + class ObserverDialog(Dialog): def __init__(self, master, app): @@ -27,7 +29,7 @@ class ObserverDialog(Dialog): def draw_listbox(self): frame = ttk.Frame(self.top) - frame.grid(sticky="nsew") + frame.grid(sticky="nsew", pady=PAD) frame.columnconfigure(0, weight=1) frame.rowconfigure(0, weight=1) @@ -46,22 +48,22 @@ class ObserverDialog(Dialog): def draw_form_fields(self): frame = ttk.Frame(self.top) - frame.grid(sticky="ew") + frame.grid(sticky="ew", pady=PAD) frame.columnconfigure(1, weight=1) label = ttk.Label(frame, text="Name") - label.grid(row=0, column=0, sticky="w") + label.grid(row=0, column=0, sticky="w", padx=PAD) entry = ttk.Entry(frame, textvariable=self.name) entry.grid(row=0, column=1, sticky="ew") label = ttk.Label(frame, text="Command") - label.grid(row=1, column=0, sticky="w") + label.grid(row=1, column=0, sticky="w", padx=PAD) entry = ttk.Entry(frame, textvariable=self.cmd) entry.grid(row=1, column=1, sticky="ew") def draw_config_buttons(self): frame = ttk.Frame(self.top) - frame.grid(pady=2, sticky="ew") + frame.grid(sticky="ew", pady=PAD) for i in range(3): frame.columnconfigure(i, weight=1) diff --git a/coretk/coretk/dialogs/preferences.py b/coretk/coretk/dialogs/preferences.py index 7298f727..b094eec6 100644 --- a/coretk/coretk/dialogs/preferences.py +++ b/coretk/coretk/dialogs/preferences.py @@ -5,6 +5,8 @@ from tkinter import ttk from coretk import appconfig from coretk.dialogs.dialog import Dialog +PAD = 5 + class PreferencesDialog(Dialog): def __init__(self, master, app): @@ -18,16 +20,17 @@ class PreferencesDialog(Dialog): def draw(self): self.top.columnconfigure(0, weight=1) + self.top.rowconfigure(0, weight=1) self.draw_preferences() self.draw_buttons() def draw_preferences(self): - frame = ttk.LabelFrame(self.top, text="Preferences") - frame.grid(sticky="ew", pady=2) + frame = ttk.LabelFrame(self.top, text="Preferences", padding=PAD) + frame.grid(sticky="nsew", pady=2) frame.columnconfigure(1, weight=1) label = ttk.Label(frame, text="Theme") - label.grid(row=0, column=0, pady=2, padx=2, sticky="w") + label.grid(row=0, column=0, pady=PAD, padx=PAD, sticky="w") themes = self.app.style.theme_names() combobox = ttk.Combobox( frame, textvariable=self.theme, values=themes, state="readonly" @@ -37,14 +40,14 @@ class PreferencesDialog(Dialog): combobox.bind("<>", self.theme_change) label = ttk.Label(frame, text="Editor") - label.grid(row=1, column=0, pady=2, padx=2, sticky="w") + label.grid(row=1, column=0, pady=PAD, padx=PAD, sticky="w") combobox = ttk.Combobox( frame, textvariable=self.editor, values=appconfig.EDITORS, state="readonly" ) combobox.grid(row=1, column=1, sticky="ew") label = ttk.Label(frame, text="Terminal") - label.grid(row=2, column=0, pady=2, padx=2, sticky="w") + label.grid(row=2, column=0, pady=PAD, padx=PAD, sticky="w") combobox = ttk.Combobox( frame, textvariable=self.terminal, @@ -54,7 +57,7 @@ class PreferencesDialog(Dialog): combobox.grid(row=2, column=1, sticky="ew") label = ttk.Label(frame, text="3D GUI") - label.grid(row=3, column=0, pady=2, padx=2, sticky="w") + label.grid(row=3, column=0, pady=PAD, padx=PAD, sticky="w") entry = ttk.Entry(frame, textvariable=self.gui3d) entry.grid(row=3, column=1, sticky="ew") diff --git a/coretk/coretk/dialogs/servers.py b/coretk/coretk/dialogs/servers.py index 9df7bf55..18c5d6d1 100644 --- a/coretk/coretk/dialogs/servers.py +++ b/coretk/coretk/dialogs/servers.py @@ -4,6 +4,7 @@ from tkinter import ttk from coretk.coreclient import CoreServer from coretk.dialogs.dialog import Dialog +PAD = 5 DEFAULT_NAME = "example" DEFAULT_ADDRESS = "127.0.0.1" DEFAULT_PORT = 50051 @@ -26,13 +27,13 @@ class ServersDialog(Dialog): self.top.columnconfigure(0, weight=1) self.top.rowconfigure(0, weight=1) self.draw_servers() - self.draw_server_configuration() self.draw_servers_buttons() + self.draw_server_configuration() self.draw_apply_buttons() def draw_servers(self): frame = ttk.Frame(self.top) - frame.grid(pady=2, sticky="nsew") + frame.grid(pady=PAD, sticky="nsew") frame.columnconfigure(0, weight=1) frame.rowconfigure(0, weight=1) @@ -51,27 +52,24 @@ class ServersDialog(Dialog): scrollbar.config(command=self.servers.yview) def draw_server_configuration(self): - label = ttk.Label(self.top, text="Server Configuration") - label.grid(pady=2, sticky="ew") - - frame = ttk.Frame(self.top) - frame.grid(pady=2, sticky="ew") + frame = ttk.LabelFrame(self.top, text="Server Configuration", padding=PAD) + frame.grid(pady=PAD, sticky="ew") frame.columnconfigure(1, weight=1) frame.columnconfigure(3, weight=1) frame.columnconfigure(5, weight=1) label = ttk.Label(frame, text="Name") - label.grid(row=0, column=0, sticky="w") + label.grid(row=0, column=0, sticky="w", padx=PAD, pady=PAD) entry = ttk.Entry(frame, textvariable=self.name) entry.grid(row=0, column=1, sticky="ew") label = ttk.Label(frame, text="Address") - label.grid(row=0, column=2, sticky="w") + label.grid(row=0, column=2, sticky="w", padx=PAD, pady=PAD) entry = ttk.Entry(frame, textvariable=self.address) entry.grid(row=0, column=3, sticky="ew") label = ttk.Label(frame, text="Port") - label.grid(row=0, column=4, sticky="w") + label.grid(row=0, column=4, sticky="w", padx=PAD, pady=PAD) entry = ttk.Entry( frame, textvariable=self.port, @@ -85,17 +83,17 @@ class ServersDialog(Dialog): def draw_servers_buttons(self): frame = ttk.Frame(self.top) - frame.grid(pady=2, sticky="ew") + frame.grid(pady=PAD, sticky="ew") for i in range(3): frame.columnconfigure(i, weight=1) button = ttk.Button(frame, text="Create", command=self.click_create) - button.grid(row=0, column=0, sticky="ew") + button.grid(row=0, column=0, sticky="ew", padx=PAD) self.save_button = ttk.Button( frame, text="Save", state=tk.DISABLED, command=self.click_save ) - self.save_button.grid(row=0, column=1, sticky="ew") + self.save_button.grid(row=0, column=1, sticky="ew", padx=PAD) self.delete_button = ttk.Button( frame, text="Delete", state=tk.DISABLED, command=self.click_delete @@ -111,7 +109,7 @@ class ServersDialog(Dialog): button = ttk.Button( frame, text="Save Configuration", command=self.click_save_configuration ) - button.grid(row=0, column=0, sticky="ew") + button.grid(row=0, column=0, sticky="ew", padx=PAD) button = ttk.Button(frame, text="Cancel", command=self.destroy) button.grid(row=0, column=1, sticky="ew") diff --git a/coretk/coretk/dialogs/sessions.py b/coretk/coretk/dialogs/sessions.py index e3d9e696..f8d26667 100644 --- a/coretk/coretk/dialogs/sessions.py +++ b/coretk/coretk/dialogs/sessions.py @@ -10,6 +10,8 @@ from coretk.dialogs.dialog import Dialog from coretk.errors import show_grpc_error from coretk.images import ImageEnum, Images +PAD = 5 + class SessionsDialog(Dialog): def __init__(self, master, app): @@ -31,6 +33,7 @@ class SessionsDialog(Dialog): def draw(self): self.top.columnconfigure(0, weight=1) + self.top.rowconfigure(1, weight=1) self.draw_description() self.draw_tree() self.draw_buttons() @@ -46,14 +49,19 @@ class SessionsDialog(Dialog): "connect to an existing session. Usually, only sessions in \n" "the RUNTIME state persist in the daemon, except for the \n" "one you might be concurrently editting.", + justify=tk.CENTER, ) - label.grid(row=0, sticky="ew", pady=5) + label.grid(pady=PAD) def draw_tree(self): + frame = ttk.Frame(self.top) + frame.columnconfigure(0, weight=1) + frame.rowconfigure(0, weight=1) + frame.grid(sticky="nsew") self.tree = ttk.Treeview( - self.top, columns=("id", "state", "nodes"), show="headings" + frame, columns=("id", "state", "nodes"), show="headings" ) - self.tree.grid(row=1, sticky="nsew") + self.tree.grid(sticky="nsew") self.tree.column("id", stretch=tk.YES) self.tree.heading("id", text="ID") self.tree.column("state", stretch=tk.YES) @@ -72,21 +80,19 @@ class SessionsDialog(Dialog): self.tree.bind("", self.on_selected) self.tree.bind("<>", self.click_select) - yscrollbar = ttk.Scrollbar(self.top, orient="vertical", command=self.tree.yview) - yscrollbar.grid(row=1, column=1, sticky="ns") + yscrollbar = ttk.Scrollbar(frame, orient="vertical", command=self.tree.yview) + yscrollbar.grid(row=0, column=1, sticky="ns") self.tree.configure(yscrollcommand=yscrollbar.set) - xscrollbar = ttk.Scrollbar( - self.top, orient="horizontal", command=self.tree.xview - ) - xscrollbar.grid(row=2, sticky="ew", pady=5) + xscrollbar = ttk.Scrollbar(frame, orient="horizontal", command=self.tree.xview) + xscrollbar.grid(row=1, sticky="ew", pady=5) self.tree.configure(xscrollcommand=xscrollbar.set) def draw_buttons(self): frame = ttk.Frame(self.top) for i in range(4): frame.columnconfigure(i, weight=1) - frame.grid(row=3, sticky="ew") + frame.grid(sticky="ew") image = Images.get(ImageEnum.DOCUMENTNEW, 16) b = ttk.Button( diff --git a/coretk/coretk/dialogs/shapemod.py b/coretk/coretk/dialogs/shapemod.py index e0085a8c..63037c9d 100644 --- a/coretk/coretk/dialogs/shapemod.py +++ b/coretk/coretk/dialogs/shapemod.py @@ -8,6 +8,8 @@ from coretk.dialogs.dialog import Dialog from coretk.graph import tags from coretk.graph.shapeutils import is_draw_shape, is_shape_text +PADX = (0, 5) +PAD = 5 FONT_SIZES = [8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72] BORDER_WIDTH = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] @@ -37,20 +39,27 @@ class ShapeDialog(Dialog): self.bold = tk.BooleanVar(value=data.bold) self.italic = tk.BooleanVar(value=data.italic) self.underline = tk.BooleanVar(value=data.underline) - self.top.columnconfigure(0, weight=1) self.draw() def draw(self): - frame = ttk.Frame(self.top) - frame.columnconfigure(0, weight=1) - frame.columnconfigure(1, weight=2) - label = ttk.Label(frame, text="Text for top of shape: ") - label.grid(row=0, column=0, sticky="nsew") - entry = ttk.Entry(frame, textvariable=self.shape_text) - entry.grid(row=0, column=1, sticky="nsew") - frame.grid(row=0, column=0, sticky="nsew", padx=3, pady=3) + self.top.columnconfigure(0, weight=1) + self.draw_label_options() + if is_draw_shape(self.shape.shape_type): + self.draw_shape_options() + self.draw_spacer() + self.draw_buttons() - frame = ttk.Frame(self.top) + def draw_label_options(self): + label_frame = ttk.LabelFrame(self.top, text="Label", padding=PAD) + label_frame.grid(sticky="ew") + label_frame.columnconfigure(0, weight=1) + + entry = ttk.Entry(label_frame, textvariable=self.shape_text) + entry.grid(sticky="ew", pady=PAD) + + # font options + frame = ttk.Frame(label_frame) + frame.grid(sticky="nsew", padx=3, pady=3) frame.columnconfigure(0, weight=1) frame.columnconfigure(1, weight=1) frame.columnconfigure(2, weight=1) @@ -65,70 +74,65 @@ class ShapeDialog(Dialog): frame, textvariable=self.font_size, values=FONT_SIZES, state="readonly" ) combobox.grid(row=0, column=1, padx=3, sticky="nsew") - button = ttk.Button(frame, text="Text color", command=self.choose_text_color) + button = ttk.Button(frame, text="Color", command=self.choose_text_color) button.grid(row=0, column=2, sticky="nsew") - frame.grid(row=1, column=0, sticky="nsew", padx=3, pady=3) - frame = ttk.Frame(self.top) + # style options + frame = ttk.Frame(label_frame) + frame.grid(sticky="ew") + for i in range(3): + frame.columnconfigure(i, weight=1) button = ttk.Checkbutton(frame, variable=self.bold, text="Bold") - button.grid(row=0, column=0) + button.grid(row=0, column=0, sticky="ew") button = ttk.Checkbutton(frame, variable=self.italic, text="Italic") - button.grid(row=0, column=1, padx=3) + button.grid(row=0, column=1, padx=3, sticky="ew") button = ttk.Checkbutton(frame, variable=self.underline, text="Underline") - button.grid(row=0, column=2) - frame.grid(row=2, column=0, sticky="nsew", padx=3, pady=3) + button.grid(row=0, column=2, sticky="ew") - if is_draw_shape(self.shape.shape_type): - frame = ttk.Frame(self.top) - frame.columnconfigure(0, weight=1) - frame.columnconfigure(1, weight=1) - frame.columnconfigure(2, weight=1) - label = ttk.Label(frame, text="Fill color") - label.grid(row=0, column=0, sticky="nsew") - self.fill = ttk.Label( - frame, text=self.fill_color, background=self.fill_color - ) - self.fill.grid(row=0, column=1, sticky="nsew", padx=3) - button = ttk.Button(frame, text="Color", command=self.choose_fill_color) - button.grid(row=0, column=2, sticky="nsew") - frame.grid(row=3, column=0, sticky="nsew", padx=3, pady=3) + def draw_shape_options(self): + label_frame = ttk.LabelFrame(self.top, text="Shape", padding=PAD) + label_frame.grid(sticky="ew", pady=PAD) + label_frame.columnconfigure(0, weight=1) - frame = ttk.Frame(self.top) - frame.columnconfigure(0, weight=1) - frame.columnconfigure(1, weight=1) - frame.columnconfigure(2, weight=1) - label = ttk.Label(frame, text="Border color:") - label.grid(row=0, column=0, sticky="nsew") - self.border = ttk.Label( - frame, text=self.border_color, background=self.fill_color - ) - self.border.grid(row=0, column=1, sticky="nsew", padx=3) - button = ttk.Button(frame, text="Color", command=self.choose_border_color) - button.grid(row=0, column=2, sticky="nsew") - frame.grid(row=4, column=0, sticky="nsew", padx=3, pady=3) + frame = ttk.Frame(label_frame) + frame.grid(sticky="ew") + for i in range(1, 3): + frame.columnconfigure(i, weight=1) + label = ttk.Label(frame, text="Fill Color") + label.grid(row=0, column=0, padx=PADX, sticky="w") + self.fill = ttk.Label(frame, text=self.fill_color, background=self.fill_color) + self.fill.grid(row=0, column=1, sticky="ew", padx=PADX) + button = ttk.Button(frame, text="Color", command=self.choose_fill_color) + button.grid(row=0, column=2, sticky="ew") - frame = ttk.Frame(self.top) - frame.columnconfigure(0, weight=1) - frame.columnconfigure(1, weight=2) - label = ttk.Label(frame, text="Border width:") - label.grid(row=0, column=0, sticky="nsew") - combobox = ttk.Combobox( - frame, - textvariable=self.border_width, - values=BORDER_WIDTH, - state="readonly", - ) - combobox.grid(row=0, column=1, sticky="nsew") - frame.grid(row=5, column=0, sticky="nsew", padx=3, pady=3) + label = ttk.Label(frame, text="Border Color") + label.grid(row=1, column=0, sticky="w", padx=PADX) + self.border = ttk.Label( + frame, text=self.border_color, background=self.border_color + ) + self.border.grid(row=1, column=1, sticky="ew", padx=PADX) + button = ttk.Button(frame, text="Color", command=self.choose_border_color) + button.grid(row=1, column=2, sticky="ew") + frame = ttk.Frame(label_frame) + frame.grid(sticky="ew", pady=PAD) + frame.columnconfigure(1, weight=1) + label = ttk.Label(frame, text="Border Width") + label.grid(row=0, column=0, sticky="w", padx=PADX) + combobox = ttk.Combobox( + frame, textvariable=self.border_width, values=BORDER_WIDTH, state="readonly" + ) + combobox.grid(row=0, column=1, sticky="nsew") + + def draw_buttons(self): frame = ttk.Frame(self.top) + frame.grid(sticky="nsew") frame.columnconfigure(0, weight=1) frame.columnconfigure(1, weight=1) button = ttk.Button(frame, text="Add shape", command=self.click_add) - button.grid(row=0, column=0, sticky="e", padx=3) + button.grid(row=0, column=0, sticky="ew", padx=PADX) button = ttk.Button(frame, text="Cancel", command=self.cancel) - button.grid(row=0, column=1, sticky="w", pady=3) - frame.grid(row=6, column=0, sticky="nsew", padx=3, pady=3) + button.grid(row=0, column=1, sticky="ew") def choose_text_color(self): color = colorchooser.askcolor(color="black") @@ -140,7 +144,7 @@ class ShapeDialog(Dialog): self.fill.config(background=color[1], text=color[1]) def choose_border_color(self): - color = colorchooser.askcolor(color="black") + color = colorchooser.askcolor(color=self.border_color) self.border_color = color[1] self.border.config(background=color[1], text=color[1]) diff --git a/coretk/coretk/dialogs/wlanconfig.py b/coretk/coretk/dialogs/wlanconfig.py index 42adc49a..711f94f0 100644 --- a/coretk/coretk/dialogs/wlanconfig.py +++ b/coretk/coretk/dialogs/wlanconfig.py @@ -30,7 +30,8 @@ class WlanConfigDialog(Dialog): def draw(self): self.top.columnconfigure(0, weight=1) - self.config_frame = ConfigFrame(self.top, self.app, self.config, borderwidth=0) + self.top.rowconfigure(0, weight=1) + self.config_frame = ConfigFrame(self.top, self.app, self.config) self.config_frame.draw_config() self.config_frame.grid(sticky="nsew", pady=PAD) self.draw_apply_buttons() diff --git a/coretk/coretk/graph/node.py b/coretk/coretk/graph/node.py index 5757f081..ef4686be 100644 --- a/coretk/coretk/graph/node.py +++ b/coretk/coretk/graph/node.py @@ -4,6 +4,7 @@ from tkinter import font import grpc from core.api.grpc.core_pb2 import NodeType +from coretk import themes from coretk.dialogs.emaneconfig import EmaneConfigDialog from coretk.dialogs.mobilityconfig import MobilityConfigDialog from coretk.dialogs.nodeconfig import NodeConfigDialog @@ -161,6 +162,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.update_menu(self.app.style, 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/menuaction.py b/coretk/coretk/menuaction.py index a9f9ca34..3115cd58 100644 --- a/coretk/coretk/menuaction.py +++ b/coretk/coretk/menuaction.py @@ -12,8 +12,8 @@ import grpc from coretk.appconfig import XML_PATH from coretk.dialogs.about import AboutDialog -from coretk.dialogs.canvasbackground import CanvasBackgroundDialog from coretk.dialogs.canvassizeandscale import SizeAndScaleDialog +from coretk.dialogs.canvaswallpaper import CanvasBackgroundDialog from coretk.dialogs.hooks import HooksDialog from coretk.dialogs.observers import ObserverDialog from coretk.dialogs.preferences import PreferencesDialog diff --git a/coretk/coretk/menubar.py b/coretk/coretk/menubar.py index ed5cb2ca..2521bd97 100644 --- a/coretk/coretk/menubar.py +++ b/coretk/coretk/menubar.py @@ -80,6 +80,7 @@ class Menubar(tk.Menu): :return: nothing """ menu = tk.Menu(self) + menu.add_command(label="Preferences", command=self.menuaction.gui_preferences) menu.add_command(label="Undo", accelerator="Ctrl+Z", state=tk.DISABLED) menu.add_command(label="Redo", accelerator="Ctrl+Y", state=tk.DISABLED) menu.add_separator() @@ -94,9 +95,6 @@ class Menubar(tk.Menu): menu.add_separator() menu.add_command(label="Find...", accelerator="Ctrl+F", state=tk.DISABLED) menu.add_command(label="Clear marker", state=tk.DISABLED) - menu.add_command( - label="Preferences...", command=self.menuaction.gui_preferences - ) self.add_cascade(label="Edit", menu=menu) def draw_canvas_menu(self): @@ -436,16 +434,14 @@ class Menubar(tk.Menu): """ menu = tk.Menu(self) menu.add_command( - label="Change sessions...", - command=self.menuaction.session_change_sessions, - underline=0, + label="Sessions...", command=self.menuaction.session_change_sessions ) menu.add_separator() - menu.add_command(label="Comments...", state=tk.DISABLED) - menu.add_command(label="Hooks...", command=self.menuaction.session_hooks) - menu.add_command(label="Reset node positions", state=tk.DISABLED) - menu.add_command(label="Servers...", command=self.menuaction.session_servers) menu.add_command(label="Options...", command=self.menuaction.session_options) + menu.add_command(label="Servers...", command=self.menuaction.session_servers) + menu.add_command(label="Hooks...", command=self.menuaction.session_hooks) + menu.add_command(label="Reset Nodes", state=tk.DISABLED) + menu.add_command(label="Comments...", state=tk.DISABLED) self.add_cascade(label="Session", menu=menu) def draw_help_menu(self): diff --git a/coretk/coretk/themes.py b/coretk/coretk/themes.py index a1982b3e..a870b278 100644 --- a/coretk/coretk/themes.py +++ b/coretk/coretk/themes.py @@ -140,15 +140,19 @@ def update_bg(style, event): event.widget.config(background=bg) -def update_menu(style, event): +def theme_change_menu(style, event): if not isinstance(event.widget, tk.Menu): return + update_menu(style, event.widget) + + +def update_menu(style, widget): bg = style.lookup(".", "background") fg = style.lookup(".", "foreground") abg = style.lookup(".", "lightcolor") if not abg: abg = bg - event.widget.config( + widget.config( background=bg, foreground=fg, activebackground=abg, activeforeground=fg ) diff --git a/coretk/coretk/widgets.py b/coretk/coretk/widgets.py index fb5582a1..e3fd5c35 100644 --- a/coretk/coretk/widgets.py +++ b/coretk/coretk/widgets.py @@ -65,7 +65,7 @@ class FrameScroll(ttk.LabelFrame): class ConfigFrame(FrameScroll): def __init__(self, master, app, config, **kw): - super().__init__(master, app, ttk.Notebook, **kw) + super().__init__(master, app, ttk.Notebook, borderwidth=0, **kw) self.app = app self.config = config self.values = {} From 899eb51c55bc2b71f575e183709a1537fafa237b Mon Sep 17 00:00:00 2001 From: Blake Harnden <32446120+bharnden@users.noreply.github.com> Date: Wed, 11 Dec 2019 14:36:27 -0800 Subject: [PATCH 3/3] added common padding for x, y, and frame paddings, to easily modify and provide consistent look and feel --- coretk/coretk/appconfig.py | 2 +- coretk/coretk/dialogs/canvassizeandscale.py | 60 +++++++++++---------- coretk/coretk/dialogs/canvaswallpaper.py | 17 +++--- coretk/coretk/dialogs/customnodes.py | 31 ++++++----- coretk/coretk/dialogs/dialog.py | 3 +- coretk/coretk/dialogs/emaneconfig.py | 23 ++++---- coretk/coretk/dialogs/hooks.py | 19 ++++--- coretk/coretk/dialogs/icondialog.py | 13 +++-- coretk/coretk/dialogs/mobilityconfig.py | 7 ++- coretk/coretk/dialogs/mobilityplayer.py | 16 +++--- coretk/coretk/dialogs/nodeconfig.py | 29 +++++----- coretk/coretk/dialogs/nodeservice.py | 19 ++++--- coretk/coretk/dialogs/observers.py | 19 ++++--- coretk/coretk/dialogs/preferences.py | 17 +++--- coretk/coretk/dialogs/servers.py | 22 ++++---- coretk/coretk/dialogs/sessionoptions.py | 10 ++-- coretk/coretk/dialogs/sessions.py | 17 +++--- coretk/coretk/dialogs/shapemod.py | 19 ++++--- coretk/coretk/dialogs/wlanconfig.py | 7 ++- coretk/coretk/themes.py | 8 ++- coretk/coretk/widgets.py | 24 ++++----- 21 files changed, 189 insertions(+), 193 deletions(-) diff --git a/coretk/coretk/appconfig.py b/coretk/coretk/appconfig.py index 0617562a..b2606994 100644 --- a/coretk/coretk/appconfig.py +++ b/coretk/coretk/appconfig.py @@ -75,7 +75,7 @@ def check_directory(): editor = EDITORS[1] config = { "preferences": { - "theme": themes.DARK, + "theme": themes.THEME_DARK, "editor": editor, "terminal": terminal, "gui3d": "/usr/local/bin/std3d.sh", diff --git a/coretk/coretk/dialogs/canvassizeandscale.py b/coretk/coretk/dialogs/canvassizeandscale.py index 1fcfff59..5a472104 100644 --- a/coretk/coretk/dialogs/canvassizeandscale.py +++ b/coretk/coretk/dialogs/canvassizeandscale.py @@ -5,8 +5,8 @@ import tkinter as tk from tkinter import font, ttk from coretk.dialogs.dialog import Dialog +from coretk.themes import FRAME_PAD, PADX, PADY -PAD = 5 PIXEL_SCALE = 100 @@ -50,17 +50,17 @@ class SizeAndScaleDialog(Dialog): self.draw_buttons() def draw_size(self): - label_frame = ttk.Labelframe(self.top, text="Size", padding=PAD) + label_frame = ttk.Labelframe(self.top, text="Size", padding=FRAME_PAD) label_frame.grid(sticky="ew") label_frame.columnconfigure(0, weight=1) # draw size row 1 frame = ttk.Frame(label_frame) - frame.grid(sticky="ew", pady=3) + frame.grid(sticky="ew", pady=PADY) frame.columnconfigure(1, weight=1) frame.columnconfigure(3, weight=1) label = ttk.Label(frame, text="Width") - label.grid(row=0, column=0, sticky="w", padx=PAD) + label.grid(row=0, column=0, sticky="w", padx=PADX) entry = ttk.Entry( frame, textvariable=self.pixel_width, @@ -68,9 +68,9 @@ class SizeAndScaleDialog(Dialog): validatecommand=(self.validation.positive_int, "%P"), ) entry.bind("", lambda event: self.validation.focus_out(event, "0")) - entry.grid(row=0, column=1, sticky="ew", padx=PAD) + entry.grid(row=0, column=1, sticky="ew", padx=PADX) label = ttk.Label(frame, text="x Height") - label.grid(row=0, column=2, sticky="w", padx=PAD) + label.grid(row=0, column=2, sticky="w", padx=PADX) entry = ttk.Entry( frame, textvariable=self.pixel_height, @@ -78,17 +78,17 @@ class SizeAndScaleDialog(Dialog): validatecommand=(self.validation.positive_int, "%P"), ) entry.bind("", lambda event: self.validation.focus_out(event, "0")) - entry.grid(row=0, column=3, sticky="ew", padx=PAD) + entry.grid(row=0, column=3, sticky="ew", padx=PADX) label = ttk.Label(frame, text="Pixels") label.grid(row=0, column=4, sticky="w") # draw size row 2 frame = ttk.Frame(label_frame) - frame.grid(sticky="ew", pady=3) + frame.grid(sticky="ew", pady=PADY) frame.columnconfigure(1, weight=1) frame.columnconfigure(3, weight=1) label = ttk.Label(frame, text="Width") - label.grid(row=0, column=0, sticky="w", padx=PAD) + label.grid(row=0, column=0, sticky="w", padx=PADX) entry = ttk.Entry( frame, textvariable=self.meters_width, @@ -96,9 +96,9 @@ class SizeAndScaleDialog(Dialog): validatecommand=(self.validation.positive_float, "%P"), ) entry.bind("", lambda event: self.validation.focus_out(event, "0")) - entry.grid(row=0, column=1, sticky="ew", padx=PAD) + entry.grid(row=0, column=1, sticky="ew", padx=PADX) label = ttk.Label(frame, text="x Height") - label.grid(row=0, column=2, sticky="w", padx=PAD) + label.grid(row=0, column=2, sticky="w", padx=PADX) entry = ttk.Entry( frame, textvariable=self.meters_height, @@ -106,12 +106,12 @@ class SizeAndScaleDialog(Dialog): validatecommand=(self.validation.positive_float, "%P"), ) entry.bind("", lambda event: self.validation.focus_out(event, "0")) - entry.grid(row=0, column=3, sticky="ew", padx=PAD) + entry.grid(row=0, column=3, sticky="ew", padx=PADX) label = ttk.Label(frame, text="Meters") label.grid(row=0, column=4, sticky="w") def draw_scale(self): - label_frame = ttk.Labelframe(self.top, text="Scale", padding=PAD) + label_frame = ttk.Labelframe(self.top, text="Scale", padding=FRAME_PAD) label_frame.grid(sticky="ew") label_frame.columnconfigure(0, weight=1) @@ -119,7 +119,7 @@ class SizeAndScaleDialog(Dialog): frame.grid(sticky="ew") frame.columnconfigure(1, weight=1) label = ttk.Label(frame, text=f"{PIXEL_SCALE} Pixels =") - label.grid(row=0, column=0, sticky="w", padx=PAD) + label.grid(row=0, column=0, sticky="w", padx=PADX) entry = ttk.Entry( frame, textvariable=self.scale, @@ -127,12 +127,14 @@ class SizeAndScaleDialog(Dialog): validatecommand=(self.validation.positive_float, "%P"), ) entry.bind("", lambda event: self.validation.focus_out(event, "0")) - entry.grid(row=0, column=1, sticky="ew", padx=PAD) + entry.grid(row=0, column=1, sticky="ew", padx=PADX) label = ttk.Label(frame, text="Meters") label.grid(row=0, column=2, sticky="w") def draw_reference_point(self): - label_frame = ttk.Labelframe(self.top, text="Reference Point", padding=PAD) + label_frame = ttk.Labelframe( + self.top, text="Reference Point", padding=FRAME_PAD + ) label_frame.grid(sticky="ew") label_frame.columnconfigure(0, weight=1) @@ -142,12 +144,12 @@ class SizeAndScaleDialog(Dialog): label.grid() frame = ttk.Frame(label_frame) - frame.grid(sticky="ew", pady=3) + frame.grid(sticky="ew", pady=PADY) frame.columnconfigure(1, weight=1) frame.columnconfigure(3, weight=1) label = ttk.Label(frame, text="X") - label.grid(row=0, column=0, sticky="w", padx=PAD) + label.grid(row=0, column=0, sticky="w", padx=PADX) entry = ttk.Entry( frame, textvariable=self.x, @@ -155,10 +157,10 @@ class SizeAndScaleDialog(Dialog): validatecommand=(self.validation.positive_float, "%P"), ) entry.bind("", lambda event: self.validation.focus_out(event, "0")) - entry.grid(row=0, column=1, sticky="ew", padx=PAD) + entry.grid(row=0, column=1, sticky="ew", padx=PADX) label = ttk.Label(frame, text="Y") - label.grid(row=0, column=2, sticky="w", padx=PAD) + label.grid(row=0, column=2, sticky="w", padx=PADX) entry = ttk.Entry( frame, textvariable=self.y, @@ -166,19 +168,19 @@ class SizeAndScaleDialog(Dialog): validatecommand=(self.validation.positive_float, "%P"), ) entry.bind("", lambda event: self.validation.focus_out(event, "0")) - entry.grid(row=0, column=3, sticky="ew", padx=PAD) + entry.grid(row=0, column=3, sticky="ew", padx=PADX) label = ttk.Label(label_frame, text="Translates To") label.grid() frame = ttk.Frame(label_frame) - frame.grid(sticky="ew", pady=3) + frame.grid(sticky="ew", pady=PADY) frame.columnconfigure(1, weight=1) frame.columnconfigure(3, weight=1) frame.columnconfigure(5, weight=1) label = ttk.Label(frame, text="Lat") - label.grid(row=0, column=0, sticky="w", padx=PAD) + label.grid(row=0, column=0, sticky="w", padx=PADX) entry = ttk.Entry( frame, textvariable=self.lat, @@ -186,10 +188,10 @@ class SizeAndScaleDialog(Dialog): validatecommand=(self.validation.positive_float, "%P"), ) entry.bind("", lambda event: self.validation.focus_out(event, "0")) - entry.grid(row=0, column=1, sticky="ew", padx=PAD) + entry.grid(row=0, column=1, sticky="ew", padx=PADX) label = ttk.Label(frame, text="Lon") - label.grid(row=0, column=2, sticky="w", padx=PAD) + label.grid(row=0, column=2, sticky="w", padx=PADX) entry = ttk.Entry( frame, textvariable=self.lon, @@ -197,10 +199,10 @@ class SizeAndScaleDialog(Dialog): validatecommand=(self.validation.positive_float, "%P"), ) entry.bind("", lambda event: self.validation.focus_out(event, "0")) - entry.grid(row=0, column=3, sticky="ew", padx=PAD) + entry.grid(row=0, column=3, sticky="ew", padx=PADX) label = ttk.Label(frame, text="Alt") - label.grid(row=0, column=4, sticky="w", padx=PAD) + label.grid(row=0, column=4, sticky="w", padx=PADX) entry = ttk.Entry( frame, textvariable=self.alt, @@ -214,7 +216,7 @@ class SizeAndScaleDialog(Dialog): button = ttk.Checkbutton( self.top, text="Save as default?", variable=self.save_default ) - button.grid(sticky="w", pady=3) + button.grid(sticky="w", pady=PADY) def draw_buttons(self): frame = ttk.Frame(self.top) @@ -223,7 +225,7 @@ class SizeAndScaleDialog(Dialog): frame.grid(sticky="ew") button = ttk.Button(frame, text="Apply", command=self.click_apply) - button.grid(row=0, column=0, sticky="ew", padx=PAD) + button.grid(row=0, column=0, sticky="ew", padx=PADX) button = ttk.Button(frame, text="Cancel", command=self.destroy) button.grid(row=0, column=1, sticky="ew") diff --git a/coretk/coretk/dialogs/canvaswallpaper.py b/coretk/coretk/dialogs/canvaswallpaper.py index bf6bf922..923e4d5f 100644 --- a/coretk/coretk/dialogs/canvaswallpaper.py +++ b/coretk/coretk/dialogs/canvaswallpaper.py @@ -8,8 +8,7 @@ from tkinter import filedialog, ttk from coretk.appconfig import BACKGROUNDS_PATH from coretk.dialogs.dialog import Dialog from coretk.images import Images - -PAD = 5 +from coretk.themes import PADX, PADY class CanvasBackgroundDialog(Dialog): @@ -43,7 +42,7 @@ class CanvasBackgroundDialog(Dialog): self.image_label = ttk.Label( self.top, text="(image preview)", width=32, anchor=tk.CENTER ) - self.image_label.grid(pady=PAD) + self.image_label.grid(pady=PADY) def draw_image_label(self): label = ttk.Label(self.top, text="Image filename: ") @@ -60,10 +59,10 @@ class CanvasBackgroundDialog(Dialog): entry = ttk.Entry(frame, textvariable=self.filename) entry.focus() - entry.grid(row=0, column=0, sticky="ew", padx=PAD) + entry.grid(row=0, column=0, sticky="ew", padx=PADX) button = ttk.Button(frame, text="...", command=self.click_open_image) - button.grid(row=0, column=1, sticky="ew", padx=PAD) + button.grid(row=0, column=1, sticky="ew", padx=PADX) button = ttk.Button(frame, text="Clear", command=self.click_clear) button.grid(row=0, column=2, sticky="ew") @@ -104,7 +103,7 @@ class CanvasBackgroundDialog(Dialog): checkbutton = ttk.Checkbutton( self.top, text="Show grid", variable=self.show_grid ) - checkbutton.grid(sticky="ew", padx=PAD) + checkbutton.grid(sticky="ew", padx=PADX) checkbutton = ttk.Checkbutton( self.top, @@ -112,16 +111,16 @@ class CanvasBackgroundDialog(Dialog): variable=self.adjust_to_dim, command=self.click_adjust_canvas, ) - checkbutton.grid(sticky="ew", padx=PAD) + checkbutton.grid(sticky="ew", padx=PADX) def draw_buttons(self): frame = ttk.Frame(self.top) - frame.grid(pady=PAD, sticky="ew") + frame.grid(pady=PADY, sticky="ew") frame.columnconfigure(0, weight=1) frame.columnconfigure(1, weight=1) button = ttk.Button(frame, text="Apply", command=self.click_apply) - button.grid(row=0, column=0, sticky="ew", padx=PAD) + button.grid(row=0, column=0, sticky="ew", padx=PADX) button = ttk.Button(frame, text="Cancel", command=self.destroy) button.grid(row=0, column=1, sticky="ew") diff --git a/coretk/coretk/dialogs/customnodes.py b/coretk/coretk/dialogs/customnodes.py index 75052e6b..d17d8d19 100644 --- a/coretk/coretk/dialogs/customnodes.py +++ b/coretk/coretk/dialogs/customnodes.py @@ -6,10 +6,9 @@ from tkinter import ttk from coretk.dialogs.dialog import Dialog from coretk.dialogs.icondialog import IconDialog from coretk.nodeutils import NodeDraw +from coretk.themes import FRAME_PAD, PADX, PADY from coretk.widgets import CheckboxList, ListboxScroll -PAD = 5 - class ServicesSelectDialog(Dialog): def __init__(self, master, app, current_services): @@ -25,11 +24,11 @@ class ServicesSelectDialog(Dialog): self.top.rowconfigure(0, weight=1) frame = ttk.Frame(self.top) - frame.grid(stick="nsew", pady=PAD) + 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=PAD) + self.groups = ListboxScroll(frame, text="Groups", padding=FRAME_PAD) self.groups.grid(row=0, column=0, sticky="nsew") for group in sorted(self.app.core.services): self.groups.listbox.insert(tk.END, group) @@ -37,11 +36,15 @@ class ServicesSelectDialog(Dialog): self.groups.listbox.selection_set(0) self.services = CheckboxList( - frame, self.app, text="Services", clicked=self.service_clicked, padding=PAD + frame, + self.app, + text="Services", + clicked=self.service_clicked, + padding=FRAME_PAD, ) self.services.grid(row=0, column=1, sticky="nsew") - self.current = ListboxScroll(frame, text="Selected", padding=PAD) + self.current = ListboxScroll(frame, text="Selected", padding=FRAME_PAD) self.current.grid(row=0, column=2, sticky="nsew") for service in sorted(self.current_services): self.current.listbox.insert(tk.END, service) @@ -51,7 +54,7 @@ class ServicesSelectDialog(Dialog): for i in range(2): frame.columnconfigure(i, weight=1) button = ttk.Button(frame, text="Save", command=self.destroy) - button.grid(row=0, column=0, sticky="ew", padx=PAD) + button.grid(row=0, column=0, sticky="ew", padx=PADX) button = ttk.Button(frame, text="Cancel", command=self.click_cancel) button.grid(row=0, column=1, sticky="ew") @@ -106,12 +109,12 @@ class CustomNodesDialog(Dialog): def draw_node_config(self): frame = ttk.Frame(self.top) - frame.grid(sticky="nsew", pady=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=PAD) - self.nodes_list.grid(row=0, column=0, sticky="nsew", padx=PAD) + self.nodes_list = ListboxScroll(frame, text="Nodes", padding=FRAME_PAD) + 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): self.nodes_list.listbox.insert(tk.END, name) @@ -130,17 +133,17 @@ class CustomNodesDialog(Dialog): def draw_node_buttons(self): frame = ttk.Frame(self.top) - frame.grid(sticky="ew", pady=PAD) + frame.grid(sticky="ew", pady=PADY) for i in range(3): frame.columnconfigure(i, weight=1) button = ttk.Button(frame, text="Create", command=self.click_create) - button.grid(row=0, column=0, sticky="ew", padx=PAD) + button.grid(row=0, column=0, sticky="ew", padx=PADX) self.edit_button = ttk.Button( frame, text="Edit", state=tk.DISABLED, command=self.click_edit ) - self.edit_button.grid(row=0, column=1, sticky="ew", padx=PAD) + self.edit_button.grid(row=0, column=1, sticky="ew", padx=PADX) self.delete_button = ttk.Button( frame, text="Delete", state=tk.DISABLED, command=self.click_delete @@ -154,7 +157,7 @@ class CustomNodesDialog(Dialog): frame.columnconfigure(i, weight=1) button = ttk.Button(frame, text="Save", command=self.click_save) - button.grid(row=0, column=0, sticky="ew", padx=PAD) + button.grid(row=0, column=0, sticky="ew", padx=PADX) button = ttk.Button(frame, text="Cancel", command=self.destroy) button.grid(row=0, column=1, sticky="ew") diff --git a/coretk/coretk/dialogs/dialog.py b/coretk/coretk/dialogs/dialog.py index 49662cc4..92d9a7db 100644 --- a/coretk/coretk/dialogs/dialog.py +++ b/coretk/coretk/dialogs/dialog.py @@ -2,8 +2,7 @@ import tkinter as tk from tkinter import ttk from coretk.images import ImageEnum, Images - -DIALOG_PAD = 5 +from coretk.themes import DIALOG_PAD class Dialog(tk.Toplevel): diff --git a/coretk/coretk/dialogs/emaneconfig.py b/coretk/coretk/dialogs/emaneconfig.py index b16f7cd4..a1c30a6f 100644 --- a/coretk/coretk/dialogs/emaneconfig.py +++ b/coretk/coretk/dialogs/emaneconfig.py @@ -11,10 +11,9 @@ import grpc from coretk.dialogs.dialog import Dialog from coretk.errors import show_grpc_error from coretk.images import ImageEnum, Images +from coretk.themes import PADX, PADY from coretk.widgets import ConfigFrame -PAD = 5 - class GlobalEmaneDialog(Dialog): def __init__(self, master, app): @@ -27,7 +26,7 @@ class GlobalEmaneDialog(Dialog): self.top.rowconfigure(0, weight=1) self.config_frame = ConfigFrame(self.top, self.app, self.app.core.emane_config) self.config_frame.draw_config() - self.config_frame.grid(sticky="nsew", pady=PAD) + self.config_frame.grid(sticky="nsew", pady=PADY) self.draw_spacer() self.draw_buttons() @@ -37,7 +36,7 @@ class GlobalEmaneDialog(Dialog): for i in range(2): frame.columnconfigure(i, weight=1) button = ttk.Button(frame, text="Apply", command=self.click_apply) - button.grid(row=0, column=0, sticky="ew", padx=PAD) + button.grid(row=0, column=0, sticky="ew", padx=PADX) button = ttk.Button(frame, text="Cancel", command=self.destroy) button.grid(row=0, column=1, sticky="ew") @@ -68,7 +67,7 @@ class EmaneModelDialog(Dialog): self.top.rowconfigure(0, weight=1) self.config_frame = ConfigFrame(self.top, self.app, self.config) self.config_frame.draw_config() - self.config_frame.grid(sticky="nsew", pady=PAD) + self.config_frame.grid(sticky="nsew", pady=PADY) self.draw_spacer() self.draw_buttons() @@ -78,7 +77,7 @@ class EmaneModelDialog(Dialog): for i in range(2): frame.columnconfigure(i, weight=1) button = ttk.Button(frame, text="Apply", command=self.click_apply) - button.grid(row=0, column=0, sticky="ew", padx=PAD) + button.grid(row=0, column=0, sticky="ew", padx=PADX) button = ttk.Button(frame, text="Cancel", command=self.destroy) button.grid(row=0, column=1, sticky="ew") @@ -126,7 +125,7 @@ class EmaneConfigDialog(Dialog): "\nusing pluggable MAC and PHY modules. Refer to the wiki for configuration option details", justify=tk.CENTER, ) - label.grid(pady=PAD) + label.grid(pady=PADY) image = Images.get(ImageEnum.EDITNODE, 16) button = ttk.Button( @@ -139,7 +138,7 @@ class EmaneConfigDialog(Dialog): ), ) button.image = image - button.grid(sticky="ew", pady=PAD) + button.grid(sticky="ew", pady=PADY) def draw_emane_models(self): """ @@ -148,7 +147,7 @@ class EmaneConfigDialog(Dialog): :return: nothing """ frame = ttk.Frame(self.top) - frame.grid(sticky="ew", pady=PAD) + frame.grid(sticky="ew", pady=PADY) frame.columnconfigure(1, weight=1) label = ttk.Label(frame, text="Model") @@ -166,7 +165,7 @@ class EmaneConfigDialog(Dialog): def draw_emane_buttons(self): frame = ttk.Frame(self.top) - frame.grid(sticky="ew", pady=PAD) + frame.grid(sticky="ew", pady=PADY) for i in range(2): frame.columnconfigure(i, weight=1) @@ -179,7 +178,7 @@ class EmaneConfigDialog(Dialog): command=self.click_model_config, ) self.emane_model_button.image = image - self.emane_model_button.grid(row=0, column=0, padx=PAD, sticky="ew") + self.emane_model_button.grid(row=0, column=0, padx=PADX, sticky="ew") image = Images.get(ImageEnum.EDITNODE, 16) button = ttk.Button( @@ -199,7 +198,7 @@ class EmaneConfigDialog(Dialog): frame.columnconfigure(i, weight=1) button = ttk.Button(frame, text="Apply", command=self.click_apply) - button.grid(row=0, column=0, padx=PAD, sticky="ew") + button.grid(row=0, column=0, padx=PADX, sticky="ew") button = ttk.Button(frame, text="Cancel", command=self.destroy) button.grid(row=0, column=1, sticky="ew") diff --git a/coretk/coretk/dialogs/hooks.py b/coretk/coretk/dialogs/hooks.py index 2850d70e..40101823 100644 --- a/coretk/coretk/dialogs/hooks.py +++ b/coretk/coretk/dialogs/hooks.py @@ -3,10 +3,9 @@ from tkinter import ttk from core.api.grpc import core_pb2 from coretk.dialogs.dialog import Dialog +from coretk.themes import PADX, PADY from coretk.widgets import CodeText -PAD = 5 - class HookDialog(Dialog): def __init__(self, master, app): @@ -23,14 +22,14 @@ class HookDialog(Dialog): # name and states frame = ttk.Frame(self.top) - frame.grid(sticky="ew", pady=PAD) + frame.grid(sticky="ew", pady=PADY) frame.columnconfigure(0, weight=2) frame.columnconfigure(1, weight=7) frame.columnconfigure(2, weight=1) label = ttk.Label(frame, text="Name") - label.grid(row=0, column=0, sticky="ew", padx=PAD) + label.grid(row=0, column=0, sticky="ew", padx=PADX) entry = ttk.Entry(frame, textvariable=self.name) - entry.grid(row=0, column=1, sticky="ew", padx=PAD) + entry.grid(row=0, column=1, sticky="ew", padx=PADX) values = tuple(x for x in core_pb2.SessionState.Enum.keys() if x != "NONE") initial_state = core_pb2.SessionState.Enum.Name(core_pb2.SessionState.RUNTIME) self.state.set(initial_state) @@ -59,7 +58,7 @@ class HookDialog(Dialog): for i in range(2): frame.columnconfigure(i, weight=1) button = ttk.Button(frame, text="Save", command=lambda: self.save()) - button.grid(row=0, column=0, sticky="ew", padx=PAD) + button.grid(row=0, column=0, sticky="ew", padx=PADX) button = ttk.Button(frame, text="Cancel", command=lambda: self.destroy()) button.grid(row=0, column=1, sticky="ew") @@ -98,7 +97,7 @@ class HooksDialog(Dialog): self.top.rowconfigure(0, weight=1) self.listbox = tk.Listbox(self.top) - self.listbox.grid(sticky="nsew", pady=PAD) + self.listbox.grid(sticky="nsew", pady=PADY) self.listbox.bind("<>", self.select) for hook_file in self.app.core.hooks: self.listbox.insert(tk.END, hook_file) @@ -108,15 +107,15 @@ class HooksDialog(Dialog): for i in range(4): frame.columnconfigure(i, weight=1) button = ttk.Button(frame, text="Create", command=self.click_create) - button.grid(row=0, column=0, sticky="ew", padx=PAD) + button.grid(row=0, column=0, sticky="ew", padx=PADX) self.edit_button = ttk.Button( frame, text="Edit", state=tk.DISABLED, command=self.click_edit ) - self.edit_button.grid(row=0, column=1, sticky="ew", padx=PAD) + self.edit_button.grid(row=0, column=1, sticky="ew", padx=PADX) self.delete_button = ttk.Button( frame, text="Delete", state=tk.DISABLED, command=self.click_delete ) - self.delete_button.grid(row=0, column=2, sticky="ew", padx=PAD) + self.delete_button.grid(row=0, column=2, sticky="ew", padx=PADX) button = ttk.Button(frame, text="Cancel", command=lambda: self.destroy()) button.grid(row=0, column=3, sticky="ew") diff --git a/coretk/coretk/dialogs/icondialog.py b/coretk/coretk/dialogs/icondialog.py index 9273a177..ecbb5d54 100644 --- a/coretk/coretk/dialogs/icondialog.py +++ b/coretk/coretk/dialogs/icondialog.py @@ -5,8 +5,7 @@ from coretk import nodeutils from coretk.appconfig import ICONS_PATH from coretk.dialogs.dialog import Dialog from coretk.images import Images - -PAD = 5 +from coretk.themes import PADX, PADY class IconDialog(Dialog): @@ -22,19 +21,19 @@ class IconDialog(Dialog): # row one frame = ttk.Frame(self.top) - frame.grid(pady=PAD, sticky="ew") + frame.grid(pady=PADY, sticky="ew") frame.columnconfigure(0, weight=1) frame.columnconfigure(1, weight=3) label = ttk.Label(frame, text="Image") - label.grid(row=0, column=0, sticky="ew", padx=PAD) + label.grid(row=0, column=0, sticky="ew", padx=PADX) entry = ttk.Entry(frame, textvariable=self.file_path) - entry.grid(row=0, column=1, sticky="ew", padx=PAD) + entry.grid(row=0, column=1, sticky="ew", padx=PADX) button = ttk.Button(frame, text="...", command=self.click_file) button.grid(row=0, column=2) # row two self.image_label = ttk.Label(self.top, image=self.image, anchor=tk.CENTER) - self.image_label.grid(pady=PAD, sticky="ew") + self.image_label.grid(pady=PADY, sticky="ew") # spacer self.draw_spacer() @@ -45,7 +44,7 @@ class IconDialog(Dialog): frame.columnconfigure(0, weight=1) frame.columnconfigure(1, weight=1) button = ttk.Button(frame, text="Apply", command=self.destroy) - button.grid(row=0, column=0, sticky="ew", padx=PAD) + button.grid(row=0, column=0, sticky="ew", padx=PADX) button = ttk.Button(frame, text="Cancel", command=self.click_cancel) button.grid(row=0, column=1, sticky="ew") diff --git a/coretk/coretk/dialogs/mobilityconfig.py b/coretk/coretk/dialogs/mobilityconfig.py index 007209dd..19dc46f4 100644 --- a/coretk/coretk/dialogs/mobilityconfig.py +++ b/coretk/coretk/dialogs/mobilityconfig.py @@ -7,10 +7,9 @@ import grpc from coretk.dialogs.dialog import Dialog from coretk.errors import show_grpc_error +from coretk.themes import PADX, PADY from coretk.widgets import ConfigFrame -PAD = 5 - class MobilityConfigDialog(Dialog): def __init__(self, master, app, canvas_node): @@ -35,7 +34,7 @@ class MobilityConfigDialog(Dialog): self.top.rowconfigure(0, weight=1) self.config_frame = ConfigFrame(self.top, self.app, self.config) self.config_frame.draw_config() - self.config_frame.grid(sticky="nsew", pady=PAD) + self.config_frame.grid(sticky="nsew", pady=PADY) self.draw_apply_buttons() def draw_apply_buttons(self): @@ -45,7 +44,7 @@ class MobilityConfigDialog(Dialog): frame.columnconfigure(i, weight=1) button = ttk.Button(frame, text="Apply", command=self.click_apply) - button.grid(row=0, column=0, padx=PAD, sticky="ew") + button.grid(row=0, column=0, padx=PADX, sticky="ew") button = ttk.Button(frame, text="Cancel", command=self.destroy) button.grid(row=0, column=1, sticky="ew") diff --git a/coretk/coretk/dialogs/mobilityplayer.py b/coretk/coretk/dialogs/mobilityplayer.py index 1e7b4dc1..f0b46499 100644 --- a/coretk/coretk/dialogs/mobilityplayer.py +++ b/coretk/coretk/dialogs/mobilityplayer.py @@ -7,8 +7,8 @@ from core.api.grpc.core_pb2 import MobilityAction from coretk.dialogs.dialog import Dialog from coretk.errors import show_grpc_error from coretk.images import ImageEnum, Images +from coretk.themes import PADX, PADY -PAD = 5 ICON_SIZE = 16 @@ -77,36 +77,36 @@ class MobilityPlayerDialog(Dialog): file_name = self.config["file"].value label = ttk.Label(self.top, text=file_name) - label.grid(sticky="ew", pady=PAD) + label.grid(sticky="ew", pady=PADY) self.progressbar = ttk.Progressbar(self.top, mode="indeterminate") - self.progressbar.grid(sticky="ew", pady=PAD) + self.progressbar.grid(sticky="ew", pady=PADY) frame = ttk.Frame(self.top) - frame.grid(sticky="ew", pady=PAD) + frame.grid(sticky="ew", pady=PADY) for i in range(3): frame.columnconfigure(i, weight=1) image = Images.get(ImageEnum.START, width=ICON_SIZE) self.play_button = ttk.Button(frame, image=image, command=self.click_play) self.play_button.image = image - self.play_button.grid(row=0, column=0, sticky="ew", padx=PAD) + self.play_button.grid(row=0, column=0, sticky="ew", padx=PADX) image = Images.get(ImageEnum.PAUSE, width=ICON_SIZE) self.pause_button = ttk.Button(frame, image=image, command=self.click_pause) self.pause_button.image = image - self.pause_button.grid(row=0, column=1, sticky="ew", padx=PAD) + self.pause_button.grid(row=0, column=1, sticky="ew", padx=PADX) image = Images.get(ImageEnum.STOP, width=ICON_SIZE) self.stop_button = ttk.Button(frame, image=image, command=self.click_stop) self.stop_button.image = image - self.stop_button.grid(row=0, column=2, sticky="ew", padx=PAD) + self.stop_button.grid(row=0, column=2, sticky="ew", padx=PADX) loop = tk.IntVar(value=int(self.config["loop"].value == "1")) checkbutton = ttk.Checkbutton( frame, text="Loop?", variable=loop, state=tk.DISABLED ) - checkbutton.grid(row=0, column=3, padx=PAD) + checkbutton.grid(row=0, column=3, padx=PADX) rate = self.config["refresh_ms"].value label = ttk.Label(frame, text=f"rate {rate} ms") diff --git a/coretk/coretk/dialogs/nodeconfig.py b/coretk/coretk/dialogs/nodeconfig.py index 619c5ee7..56c2a08d 100644 --- a/coretk/coretk/dialogs/nodeconfig.py +++ b/coretk/coretk/dialogs/nodeconfig.py @@ -7,10 +7,9 @@ from coretk.dialogs.dialog import Dialog from coretk.dialogs.icondialog import IconDialog from coretk.dialogs.nodeservice import NodeService from coretk.nodeutils import NodeUtils +from coretk.themes import FRAME_PAD, PADX, PADY from coretk.widgets import FrameScroll -PAD = 5 - def mac_auto(is_auto, entry): logging.info("mac auto clicked") @@ -68,7 +67,7 @@ class NodeConfigDialog(Dialog): # icon field label = ttk.Label(frame, text="Icon") - label.grid(row=row, column=0, sticky="ew", padx=PAD, pady=PAD) + label.grid(row=row, column=0, sticky="ew", padx=PADX, pady=PADY) self.image_button = ttk.Button( frame, text="Icon", @@ -81,7 +80,7 @@ class NodeConfigDialog(Dialog): # name field label = ttk.Label(frame, text="Name") - label.grid(row=row, column=0, sticky="ew", padx=PAD, pady=PAD) + label.grid(row=row, column=0, sticky="ew", padx=PADX, pady=PADY) entry = ttk.Entry( frame, textvariable=self.name, @@ -97,7 +96,7 @@ class NodeConfigDialog(Dialog): # node type field if NodeUtils.is_model_node(self.node.type): label = ttk.Label(frame, text="Type") - label.grid(row=row, column=0, sticky="ew", padx=PAD, pady=PAD) + label.grid(row=row, column=0, sticky="ew", padx=PADX, pady=PADY) combobox = ttk.Combobox( frame, textvariable=self.type, @@ -110,7 +109,7 @@ class NodeConfigDialog(Dialog): # container image field if NodeUtils.is_image_node(self.node.type): label = ttk.Label(frame, text="Image") - label.grid(row=row, column=0, sticky="ew", padx=PAD, pady=PAD) + label.grid(row=row, column=0, sticky="ew", padx=PADX, pady=PADY) entry = ttk.Entry(frame, textvariable=self.container_image) entry.grid(row=row, column=1, sticky="ew") row += 1 @@ -120,7 +119,7 @@ class NodeConfigDialog(Dialog): frame.grid(sticky="ew") frame.columnconfigure(1, weight=1) label = ttk.Label(frame, text="Server") - label.grid(row=row, column=0, sticky="ew", padx=PAD, pady=PAD) + label.grid(row=row, column=0, sticky="ew", padx=PADX, pady=PADY) servers = ["localhost"] servers.extend(list(sorted(self.app.core.servers.keys()))) combobox = ttk.Combobox( @@ -131,7 +130,7 @@ class NodeConfigDialog(Dialog): # services button = ttk.Button(self.top, text="Services", command=self.click_services) - button.grid(sticky="ew", pady=PAD) + button.grid(sticky="ew", pady=PADY) # interfaces if self.canvas_node.interfaces: @@ -147,17 +146,17 @@ class NodeConfigDialog(Dialog): scroll.frame.rowconfigure(0, weight=1) for interface in self.canvas_node.interfaces: logging.info("interface: %s", interface) - frame = ttk.LabelFrame(scroll.frame, text=interface.name, padding=PAD) - frame.grid(sticky="ew", pady=PAD) + frame = ttk.LabelFrame(scroll.frame, text=interface.name, padding=FRAME_PAD) + frame.grid(sticky="ew", pady=PADY) frame.columnconfigure(1, weight=1) frame.columnconfigure(2, weight=1) label = ttk.Label(frame, text="MAC") - label.grid(row=0, column=0, padx=PAD, pady=PAD) + label.grid(row=0, column=0, padx=PADX, pady=PADY) is_auto = tk.BooleanVar(value=True) checkbutton = ttk.Checkbutton(frame, text="Auto?", variable=is_auto) checkbutton.var = is_auto - checkbutton.grid(row=0, column=1, padx=PAD) + checkbutton.grid(row=0, column=1, padx=PADX) mac = tk.StringVar(value=interface.mac) entry = ttk.Entry(frame, textvariable=mac, state=tk.DISABLED) entry.grid(row=0, column=2, sticky="ew") @@ -165,14 +164,14 @@ class NodeConfigDialog(Dialog): checkbutton.config(command=func) label = ttk.Label(frame, text="IPv4") - label.grid(row=1, column=0, padx=PAD, pady=PAD) + label.grid(row=1, column=0, padx=PADX, pady=PADY) ip4 = tk.StringVar(value=f"{interface.ip4}/{interface.ip4mask}") entry = ttk.Entry(frame, textvariable=ip4) entry.bind("", self.app.validation.ip_focus_out) entry.grid(row=1, column=1, columnspan=2, sticky="ew") label = ttk.Label(frame, text="IPv6") - label.grid(row=2, column=0, padx=PAD, pady=PAD) + label.grid(row=2, column=0, padx=PADX, pady=PADY) ip6 = tk.StringVar(value=f"{interface.ip6}/{interface.ip6mask}") entry = ttk.Entry(frame, textvariable=ip6) entry.bind("", self.app.validation.ip_focus_out) @@ -187,7 +186,7 @@ class NodeConfigDialog(Dialog): frame.columnconfigure(1, weight=1) button = ttk.Button(frame, text="Apply", command=self.config_apply) - button.grid(row=0, column=0, padx=2, sticky="ew") + button.grid(row=0, column=0, padx=PADX, sticky="ew") button = ttk.Button(frame, text="Cancel", command=self.destroy) button.grid(row=0, column=1, sticky="ew") diff --git a/coretk/coretk/dialogs/nodeservice.py b/coretk/coretk/dialogs/nodeservice.py index dfcef922..c49aea50 100644 --- a/coretk/coretk/dialogs/nodeservice.py +++ b/coretk/coretk/dialogs/nodeservice.py @@ -6,10 +6,9 @@ from tkinter import messagebox, ttk from coretk.dialogs.dialog import Dialog from coretk.dialogs.serviceconfiguration import ServiceConfiguration +from coretk.themes import FRAME_PAD, PADX, PADY from coretk.widgets import CheckboxList, ListboxScroll -PAD = 5 - class NodeService(Dialog): def __init__(self, master, app, canvas_node, services=None): @@ -36,11 +35,11 @@ class NodeService(Dialog): self.top.rowconfigure(0, weight=1) frame = ttk.Frame(self.top) - frame.grid(stick="nsew") + 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=PAD) + self.groups = ListboxScroll(frame, text="Groups", padding=FRAME_PAD) self.groups.grid(row=0, column=0, sticky="nsew") for group in sorted(self.app.core.services): self.groups.listbox.insert(tk.END, group) @@ -48,11 +47,15 @@ class NodeService(Dialog): self.groups.listbox.selection_set(0) self.services = CheckboxList( - frame, self.app, text="Services", clicked=self.service_clicked, padding=PAD + frame, + self.app, + text="Services", + clicked=self.service_clicked, + padding=FRAME_PAD, ) self.services.grid(row=0, column=1, sticky="nsew") - self.current = ListboxScroll(frame, text="Selected", padding=PAD) + self.current = ListboxScroll(frame, text="Selected", padding=FRAME_PAD) self.current.grid(row=0, column=2, sticky="nsew") for service in sorted(self.current_services): self.current.listbox.insert(tk.END, service) @@ -62,9 +65,9 @@ class NodeService(Dialog): for i in range(3): frame.columnconfigure(i, weight=1) button = ttk.Button(frame, text="Configure", command=self.click_configure) - button.grid(row=0, column=0, sticky="ew", padx=PAD) + button.grid(row=0, column=0, sticky="ew", padx=PADX) button = ttk.Button(frame, text="Save", command=self.click_save) - button.grid(row=0, column=1, sticky="ew", padx=PAD) + button.grid(row=0, column=1, sticky="ew", padx=PADX) button = ttk.Button(frame, text="Cancel", command=self.click_cancel) button.grid(row=0, column=2, sticky="ew") diff --git a/coretk/coretk/dialogs/observers.py b/coretk/coretk/dialogs/observers.py index 525939e0..f496f7ef 100644 --- a/coretk/coretk/dialogs/observers.py +++ b/coretk/coretk/dialogs/observers.py @@ -3,8 +3,7 @@ from tkinter import ttk from coretk.coreclient import Observer from coretk.dialogs.dialog import Dialog - -PAD = 5 +from coretk.themes import PADX, PADY class ObserverDialog(Dialog): @@ -29,7 +28,7 @@ class ObserverDialog(Dialog): def draw_listbox(self): frame = ttk.Frame(self.top) - frame.grid(sticky="nsew", pady=PAD) + frame.grid(sticky="nsew", pady=PADY) frame.columnconfigure(0, weight=1) frame.rowconfigure(0, weight=1) @@ -48,32 +47,32 @@ class ObserverDialog(Dialog): def draw_form_fields(self): frame = ttk.Frame(self.top) - frame.grid(sticky="ew", pady=PAD) + frame.grid(sticky="ew", pady=PADY) frame.columnconfigure(1, weight=1) label = ttk.Label(frame, text="Name") - label.grid(row=0, column=0, sticky="w", padx=PAD) + label.grid(row=0, column=0, sticky="w", padx=PADX) entry = ttk.Entry(frame, textvariable=self.name) entry.grid(row=0, column=1, sticky="ew") label = ttk.Label(frame, text="Command") - label.grid(row=1, column=0, sticky="w", padx=PAD) + label.grid(row=1, column=0, sticky="w", padx=PADX) entry = ttk.Entry(frame, textvariable=self.cmd) entry.grid(row=1, column=1, sticky="ew") def draw_config_buttons(self): frame = ttk.Frame(self.top) - frame.grid(sticky="ew", pady=PAD) + frame.grid(sticky="ew", pady=PADY) for i in range(3): frame.columnconfigure(i, weight=1) button = ttk.Button(frame, text="Create", command=self.click_create) - button.grid(row=0, column=0, sticky="ew") + button.grid(row=0, column=0, sticky="ew", padx=PADX) self.save_button = ttk.Button( frame, text="Save", state=tk.DISABLED, command=self.click_save ) - self.save_button.grid(row=0, column=1, sticky="ew") + self.save_button.grid(row=0, column=1, sticky="ew", padx=PADX) self.delete_button = ttk.Button( frame, text="Delete", state=tk.DISABLED, command=self.click_delete @@ -87,7 +86,7 @@ class ObserverDialog(Dialog): frame.columnconfigure(i, weight=1) button = ttk.Button(frame, text="Save", command=self.click_save_config) - button.grid(row=0, column=0, sticky="ew") + button.grid(row=0, column=0, sticky="ew", padx=PADX) button = ttk.Button(frame, text="Cancel", command=self.destroy) button.grid(row=0, column=1, sticky="ew") diff --git a/coretk/coretk/dialogs/preferences.py b/coretk/coretk/dialogs/preferences.py index b094eec6..8c369027 100644 --- a/coretk/coretk/dialogs/preferences.py +++ b/coretk/coretk/dialogs/preferences.py @@ -4,8 +4,7 @@ from tkinter import ttk from coretk import appconfig from coretk.dialogs.dialog import Dialog - -PAD = 5 +from coretk.themes import FRAME_PAD, PADX, PADY class PreferencesDialog(Dialog): @@ -25,12 +24,12 @@ class PreferencesDialog(Dialog): self.draw_buttons() def draw_preferences(self): - frame = ttk.LabelFrame(self.top, text="Preferences", padding=PAD) - frame.grid(sticky="nsew", pady=2) + frame = ttk.LabelFrame(self.top, text="Preferences", padding=FRAME_PAD) + frame.grid(sticky="nsew", pady=PADY) frame.columnconfigure(1, weight=1) label = ttk.Label(frame, text="Theme") - label.grid(row=0, column=0, pady=PAD, padx=PAD, sticky="w") + label.grid(row=0, column=0, pady=PADY, padx=PADX, sticky="w") themes = self.app.style.theme_names() combobox = ttk.Combobox( frame, textvariable=self.theme, values=themes, state="readonly" @@ -40,14 +39,14 @@ class PreferencesDialog(Dialog): combobox.bind("<>", self.theme_change) label = ttk.Label(frame, text="Editor") - label.grid(row=1, column=0, pady=PAD, padx=PAD, sticky="w") + label.grid(row=1, column=0, pady=PADY, padx=PADX, sticky="w") combobox = ttk.Combobox( frame, textvariable=self.editor, values=appconfig.EDITORS, state="readonly" ) combobox.grid(row=1, column=1, sticky="ew") label = ttk.Label(frame, text="Terminal") - label.grid(row=2, column=0, pady=PAD, padx=PAD, sticky="w") + label.grid(row=2, column=0, pady=PADY, padx=PADX, sticky="w") combobox = ttk.Combobox( frame, textvariable=self.terminal, @@ -57,7 +56,7 @@ class PreferencesDialog(Dialog): combobox.grid(row=2, column=1, sticky="ew") label = ttk.Label(frame, text="3D GUI") - label.grid(row=3, column=0, pady=PAD, padx=PAD, sticky="w") + label.grid(row=3, column=0, pady=PADY, padx=PADX, sticky="w") entry = ttk.Entry(frame, textvariable=self.gui3d) entry.grid(row=3, column=1, sticky="ew") @@ -68,7 +67,7 @@ class PreferencesDialog(Dialog): frame.columnconfigure(i, weight=1) button = ttk.Button(frame, text="Save", command=self.click_save) - button.grid(row=0, column=0, sticky="ew") + button.grid(row=0, column=0, sticky="ew", padx=PADX) button = ttk.Button(frame, text="Cancel", command=self.destroy) button.grid(row=0, column=1, sticky="ew") diff --git a/coretk/coretk/dialogs/servers.py b/coretk/coretk/dialogs/servers.py index 18c5d6d1..ef406ecb 100644 --- a/coretk/coretk/dialogs/servers.py +++ b/coretk/coretk/dialogs/servers.py @@ -3,8 +3,8 @@ from tkinter import ttk from coretk.coreclient import CoreServer from coretk.dialogs.dialog import Dialog +from coretk.themes import FRAME_PAD, PADX, PADY -PAD = 5 DEFAULT_NAME = "example" DEFAULT_ADDRESS = "127.0.0.1" DEFAULT_PORT = 50051 @@ -33,7 +33,7 @@ class ServersDialog(Dialog): def draw_servers(self): frame = ttk.Frame(self.top) - frame.grid(pady=PAD, sticky="nsew") + frame.grid(pady=PADY, sticky="nsew") frame.columnconfigure(0, weight=1) frame.rowconfigure(0, weight=1) @@ -52,24 +52,24 @@ class ServersDialog(Dialog): scrollbar.config(command=self.servers.yview) def draw_server_configuration(self): - frame = ttk.LabelFrame(self.top, text="Server Configuration", padding=PAD) - frame.grid(pady=PAD, sticky="ew") + frame = ttk.LabelFrame(self.top, text="Server Configuration", padding=FRAME_PAD) + frame.grid(pady=PADY, sticky="ew") frame.columnconfigure(1, weight=1) frame.columnconfigure(3, weight=1) frame.columnconfigure(5, weight=1) label = ttk.Label(frame, text="Name") - label.grid(row=0, column=0, sticky="w", padx=PAD, pady=PAD) + label.grid(row=0, column=0, sticky="w", padx=PADX, pady=PADY) entry = ttk.Entry(frame, textvariable=self.name) entry.grid(row=0, column=1, sticky="ew") label = ttk.Label(frame, text="Address") - label.grid(row=0, column=2, sticky="w", padx=PAD, pady=PAD) + label.grid(row=0, column=2, sticky="w", padx=PADX, pady=PADY) entry = ttk.Entry(frame, textvariable=self.address) entry.grid(row=0, column=3, sticky="ew") label = ttk.Label(frame, text="Port") - label.grid(row=0, column=4, sticky="w", padx=PAD, pady=PAD) + label.grid(row=0, column=4, sticky="w", padx=PADX, pady=PADY) entry = ttk.Entry( frame, textvariable=self.port, @@ -83,17 +83,17 @@ class ServersDialog(Dialog): def draw_servers_buttons(self): frame = ttk.Frame(self.top) - frame.grid(pady=PAD, sticky="ew") + frame.grid(pady=PADY, sticky="ew") for i in range(3): frame.columnconfigure(i, weight=1) button = ttk.Button(frame, text="Create", command=self.click_create) - button.grid(row=0, column=0, sticky="ew", padx=PAD) + button.grid(row=0, column=0, sticky="ew", padx=PADX) self.save_button = ttk.Button( frame, text="Save", state=tk.DISABLED, command=self.click_save ) - self.save_button.grid(row=0, column=1, sticky="ew", padx=PAD) + self.save_button.grid(row=0, column=1, sticky="ew", padx=PADX) self.delete_button = ttk.Button( frame, text="Delete", state=tk.DISABLED, command=self.click_delete @@ -109,7 +109,7 @@ class ServersDialog(Dialog): button = ttk.Button( frame, text="Save Configuration", command=self.click_save_configuration ) - button.grid(row=0, column=0, sticky="ew", padx=PAD) + button.grid(row=0, column=0, sticky="ew", padx=PADX) button = ttk.Button(frame, text="Cancel", command=self.destroy) button.grid(row=0, column=1, sticky="ew") diff --git a/coretk/coretk/dialogs/sessionoptions.py b/coretk/coretk/dialogs/sessionoptions.py index 7c77f9df..24ff7381 100644 --- a/coretk/coretk/dialogs/sessionoptions.py +++ b/coretk/coretk/dialogs/sessionoptions.py @@ -5,11 +5,9 @@ import grpc from coretk.dialogs.dialog import Dialog from coretk.errors import show_grpc_error +from coretk.themes import PADX, PADY from coretk.widgets import ConfigFrame -PAD_X = 2 -PAD_Y = 2 - class SessionOptionsDialog(Dialog): def __init__(self, master, app): @@ -33,16 +31,16 @@ class SessionOptionsDialog(Dialog): self.config_frame = ConfigFrame(self.top, self.app, config=self.config) self.config_frame.draw_config() - self.config_frame.grid(sticky="nsew") + self.config_frame.grid(sticky="nsew", pady=PADY) frame = ttk.Frame(self.top) frame.grid(sticky="ew") for i in range(2): frame.columnconfigure(i, weight=1) button = ttk.Button(frame, text="Save", command=self.save) - button.grid(row=0, column=0, pady=PAD_Y, padx=PAD_X, sticky="ew") + button.grid(row=0, column=0, padx=PADX, sticky="ew") button = ttk.Button(frame, text="Cancel", command=self.destroy) - button.grid(row=0, column=1, pady=PAD_Y, padx=PAD_X, sticky="ew") + button.grid(row=0, column=1, padx=PADX, sticky="ew") def save(self): config = self.config_frame.parse_config() diff --git a/coretk/coretk/dialogs/sessions.py b/coretk/coretk/dialogs/sessions.py index f8d26667..b1fb970f 100644 --- a/coretk/coretk/dialogs/sessions.py +++ b/coretk/coretk/dialogs/sessions.py @@ -9,8 +9,7 @@ from core.api.grpc import core_pb2 from coretk.dialogs.dialog import Dialog from coretk.errors import show_grpc_error from coretk.images import ImageEnum, Images - -PAD = 5 +from coretk.themes import PADX, PADY class SessionsDialog(Dialog): @@ -51,13 +50,13 @@ class SessionsDialog(Dialog): "one you might be concurrently editting.", justify=tk.CENTER, ) - label.grid(pady=PAD) + label.grid(pady=PADY) def draw_tree(self): frame = ttk.Frame(self.top) frame.columnconfigure(0, weight=1) frame.rowconfigure(0, weight=1) - frame.grid(sticky="nsew") + frame.grid(sticky="nsew", pady=PADY) self.tree = ttk.Treeview( frame, columns=("id", "state", "nodes"), show="headings" ) @@ -85,7 +84,7 @@ class SessionsDialog(Dialog): self.tree.configure(yscrollcommand=yscrollbar.set) xscrollbar = ttk.Scrollbar(frame, orient="horizontal", command=self.tree.xview) - xscrollbar.grid(row=1, sticky="ew", pady=5) + xscrollbar.grid(row=1, sticky="ew") self.tree.configure(xscrollcommand=xscrollbar.set) def draw_buttons(self): @@ -99,7 +98,7 @@ class SessionsDialog(Dialog): frame, image=image, text="New", compound=tk.LEFT, command=self.click_new ) b.image = image - b.grid(row=0, padx=2, sticky="ew") + b.grid(row=0, padx=PADX, sticky="ew") image = Images.get(ImageEnum.FILEOPEN, 16) b = ttk.Button( @@ -110,7 +109,7 @@ class SessionsDialog(Dialog): command=self.click_connect, ) b.image = image - b.grid(row=0, column=1, padx=2, sticky="ew") + b.grid(row=0, column=1, padx=PADX, sticky="ew") image = Images.get(ImageEnum.EDITDELETE, 16) b = ttk.Button( @@ -121,10 +120,10 @@ class SessionsDialog(Dialog): command=self.click_shutdown, ) b.image = image - b.grid(row=0, column=2, padx=2, sticky="ew") + b.grid(row=0, column=2, padx=PADX, sticky="ew") b = ttk.Button(frame, text="Cancel", command=self.click_new) - b.grid(row=0, column=3, padx=2, sticky="ew") + b.grid(row=0, column=3, sticky="ew") def click_new(self): self.app.core.create_new_session() diff --git a/coretk/coretk/dialogs/shapemod.py b/coretk/coretk/dialogs/shapemod.py index 63037c9d..a6da0e3b 100644 --- a/coretk/coretk/dialogs/shapemod.py +++ b/coretk/coretk/dialogs/shapemod.py @@ -7,9 +7,8 @@ from tkinter import colorchooser, font, ttk from coretk.dialogs.dialog import Dialog from coretk.graph import tags from coretk.graph.shapeutils import is_draw_shape, is_shape_text +from coretk.themes import FRAME_PAD, PADX, PADY -PADX = (0, 5) -PAD = 5 FONT_SIZES = [8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72] BORDER_WIDTH = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] @@ -50,16 +49,16 @@ class ShapeDialog(Dialog): self.draw_buttons() def draw_label_options(self): - label_frame = ttk.LabelFrame(self.top, text="Label", padding=PAD) + label_frame = ttk.LabelFrame(self.top, text="Label", padding=FRAME_PAD) label_frame.grid(sticky="ew") label_frame.columnconfigure(0, weight=1) entry = ttk.Entry(label_frame, textvariable=self.shape_text) - entry.grid(sticky="ew", pady=PAD) + entry.grid(sticky="ew", pady=PADY) # font options frame = ttk.Frame(label_frame) - frame.grid(sticky="nsew", padx=3, pady=3) + frame.grid(sticky="nsew", pady=PADY) frame.columnconfigure(0, weight=1) frame.columnconfigure(1, weight=1) frame.columnconfigure(2, weight=1) @@ -73,7 +72,7 @@ class ShapeDialog(Dialog): combobox = ttk.Combobox( frame, textvariable=self.font_size, values=FONT_SIZES, state="readonly" ) - combobox.grid(row=0, column=1, padx=3, sticky="nsew") + combobox.grid(row=0, column=1, padx=PADX, sticky="nsew") button = ttk.Button(frame, text="Color", command=self.choose_text_color) button.grid(row=0, column=2, sticky="nsew") @@ -85,13 +84,13 @@ class ShapeDialog(Dialog): button = ttk.Checkbutton(frame, variable=self.bold, text="Bold") button.grid(row=0, column=0, sticky="ew") button = ttk.Checkbutton(frame, variable=self.italic, text="Italic") - button.grid(row=0, column=1, padx=3, sticky="ew") + button.grid(row=0, column=1, padx=PADX, sticky="ew") button = ttk.Checkbutton(frame, variable=self.underline, text="Underline") button.grid(row=0, column=2, sticky="ew") def draw_shape_options(self): - label_frame = ttk.LabelFrame(self.top, text="Shape", padding=PAD) - label_frame.grid(sticky="ew", pady=PAD) + label_frame = ttk.LabelFrame(self.top, text="Shape", padding=FRAME_PAD) + label_frame.grid(sticky="ew", pady=PADY) label_frame.columnconfigure(0, weight=1) frame = ttk.Frame(label_frame) @@ -115,7 +114,7 @@ class ShapeDialog(Dialog): button.grid(row=1, column=2, sticky="ew") frame = ttk.Frame(label_frame) - frame.grid(sticky="ew", pady=PAD) + frame.grid(sticky="ew", pady=PADY) frame.columnconfigure(1, weight=1) label = ttk.Label(frame, text="Border Width") label.grid(row=0, column=0, sticky="w", padx=PADX) diff --git a/coretk/coretk/dialogs/wlanconfig.py b/coretk/coretk/dialogs/wlanconfig.py index 711f94f0..aed411b8 100644 --- a/coretk/coretk/dialogs/wlanconfig.py +++ b/coretk/coretk/dialogs/wlanconfig.py @@ -8,10 +8,9 @@ import grpc from coretk.dialogs.dialog import Dialog from coretk.errors import show_grpc_error +from coretk.themes import PADX, PADY from coretk.widgets import ConfigFrame -PAD = 5 - class WlanConfigDialog(Dialog): def __init__(self, master, app, canvas_node): @@ -33,7 +32,7 @@ class WlanConfigDialog(Dialog): self.top.rowconfigure(0, weight=1) self.config_frame = ConfigFrame(self.top, self.app, self.config) self.config_frame.draw_config() - self.config_frame.grid(sticky="nsew", pady=PAD) + self.config_frame.grid(sticky="nsew", pady=PADY) self.draw_apply_buttons() def draw_apply_buttons(self): @@ -48,7 +47,7 @@ class WlanConfigDialog(Dialog): frame.columnconfigure(i, weight=1) button = ttk.Button(frame, text="Apply", command=self.click_apply) - button.grid(row=0, column=0, padx=PAD, sticky="ew") + button.grid(row=0, column=0, padx=PADX, sticky="ew") button = ttk.Button(frame, text="Cancel", command=self.destroy) button.grid(row=0, column=1, sticky="ew") diff --git a/coretk/coretk/themes.py b/coretk/coretk/themes.py index a870b278..cb8a8b06 100644 --- a/coretk/coretk/themes.py +++ b/coretk/coretk/themes.py @@ -1,7 +1,11 @@ import logging import tkinter as tk -DARK = "black" +THEME_DARK = "black" +PADX = (0, 5) +PADY = (0, 5) +FRAME_PAD = 5 +DIALOG_PAD = 5 class Styles: @@ -28,7 +32,7 @@ class Colors: def load(style): style.theme_create( - DARK, + THEME_DARK, "clam", { ".": { diff --git a/coretk/coretk/widgets.py b/coretk/coretk/widgets.py index e3fd5c35..cdbfea28 100644 --- a/coretk/coretk/widgets.py +++ b/coretk/coretk/widgets.py @@ -5,6 +5,7 @@ from tkinter import filedialog, font, ttk from tkinter.scrolledtext import ScrolledText from core.api.grpc import core_pb2 +from coretk.themes import FRAME_PAD, PADX, PADY INT_TYPES = { core_pb2.ConfigOptionType.UINT8, @@ -16,7 +17,6 @@ INT_TYPES = { core_pb2.ConfigOptionType.INT32, core_pb2.ConfigOptionType.INT64, } -PAD = 5 def file_button_click(value): @@ -71,8 +71,6 @@ class ConfigFrame(FrameScroll): self.values = {} def draw_config(self): - padx = 2 - pady = 2 group_mapping = {} for key in self.config: option = self.config[key] @@ -81,19 +79,19 @@ class ConfigFrame(FrameScroll): for group_name in sorted(group_mapping): group = group_mapping[group_name] - frame = ttk.Frame(self.frame, padding=PAD) + frame = ttk.Frame(self.frame, padding=FRAME_PAD) frame.columnconfigure(1, weight=1) self.frame.add(frame, text=group_name) for index, option in enumerate(sorted(group, key=lambda x: x.name)): label = ttk.Label(frame, text=option.label) - label.grid(row=index, pady=pady, padx=padx, sticky="w") + label.grid(row=index, pady=PADY, padx=PADX, sticky="w") value = tk.StringVar() if option.type == core_pb2.ConfigOptionType.BOOL: select = tuple(option.select) combobox = ttk.Combobox( frame, textvariable=value, values=select, state="readonly" ) - combobox.grid(row=index, column=1, sticky="ew", pady=pady) + combobox.grid(row=index, column=1, sticky="ew") if option.value == "1": value.set("On") else: @@ -104,15 +102,15 @@ class ConfigFrame(FrameScroll): combobox = ttk.Combobox( frame, textvariable=value, values=select, state="readonly" ) - combobox.grid(row=index, column=1, sticky="ew", pady=pady) + combobox.grid(row=index, column=1, sticky="ew") elif option.type == core_pb2.ConfigOptionType.STRING: value.set(option.value) if "file" in option.label: file_frame = ttk.Frame(frame) - file_frame.grid(row=index, column=1, sticky="ew", pady=pady) + file_frame.grid(row=index, column=1, sticky="ew") file_frame.columnconfigure(0, weight=1) entry = ttk.Entry(file_frame, textvariable=value) - entry.grid(row=0, column=0, sticky="ew", padx=padx) + entry.grid(row=0, column=0, sticky="ew", padx=PADX) func = partial(file_button_click, value) button = ttk.Button(file_frame, text="...", command=func) button.grid(row=0, column=1) @@ -124,10 +122,10 @@ class ConfigFrame(FrameScroll): validate="key", validatecommand=(self.app.validation.ip4, "%P"), ) - entry.grid(row=index, column=1, sticky="ew", pady=pady) + entry.grid(row=index, column=1, sticky="ew") else: entry = ttk.Entry(frame, textvariable=value) - entry.grid(row=index, column=1, sticky="ew", pady=pady) + entry.grid(row=index, column=1, sticky="ew") elif option.type in INT_TYPES: value.set(option.value) @@ -141,7 +139,7 @@ class ConfigFrame(FrameScroll): "", lambda event: self.app.validation.focus_out(event, "0"), ) - entry.grid(row=index, column=1, sticky="ew", pady=pady) + entry.grid(row=index, column=1, sticky="ew") elif option.type == core_pb2.ConfigOptionType.FLOAT: value.set(option.value) entry = ttk.Entry( @@ -154,7 +152,7 @@ class ConfigFrame(FrameScroll): "", lambda event: self.app.validation.focus_out(event, "0"), ) - entry.grid(row=index, column=1, sticky="ew", pady=pady) + entry.grid(row=index, column=1, sticky="ew") else: logging.error("unhandled config option type: %s", option.type) self.values[option.name] = value