pygui: updates to leverage tk provided constants for sticky configuration, instead of duplicate strings everywhere

This commit is contained in:
Blake Harnden 2020-08-02 10:36:14 -07:00
parent 2aeb119b04
commit f0bc3bbc99
40 changed files with 501 additions and 496 deletions

View file

@ -27,14 +27,14 @@ class HookDialog(Dialog):
# name and states
frame = ttk.Frame(self.top)
frame.grid(sticky="ew", pady=PADY)
frame.grid(sticky=tk.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=PADX)
label.grid(row=0, column=0, sticky=tk.EW, padx=PADX)
entry = ttk.Entry(frame, textvariable=self.name)
entry.grid(row=0, column=1, sticky="ew", padx=PADX)
entry.grid(row=0, column=1, sticky=tk.EW, padx=PADX)
values = tuple(x.name for x in SessionState)
initial_state = SessionState.RUNTIME.name
self.state.set(initial_state)
@ -42,7 +42,7 @@ class HookDialog(Dialog):
combobox = ttk.Combobox(
frame, textvariable=self.state, values=values, state="readonly"
)
combobox.grid(row=0, column=2, sticky="ew")
combobox.grid(row=0, column=2, sticky=tk.EW)
combobox.bind("<<ComboboxSelected>>", self.state_change)
# data
@ -55,17 +55,17 @@ class HookDialog(Dialog):
"# specified state\n"
),
)
self.codetext.grid(sticky="nsew", pady=PADY)
self.codetext.grid(sticky=tk.NSEW, pady=PADY)
# button row
frame = ttk.Frame(self.top)
frame.grid(sticky="ew")
frame.grid(sticky=tk.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", padx=PADX)
button.grid(row=0, column=0, sticky=tk.EW, padx=PADX)
button = ttk.Button(frame, text="Cancel", command=lambda: self.destroy())
button.grid(row=0, column=1, sticky="ew")
button.grid(row=0, column=1, sticky=tk.EW)
def state_change(self, event: tk.Event) -> None:
if self.editing:
@ -110,7 +110,7 @@ class HooksDialog(Dialog):
self.top.rowconfigure(0, weight=1)
listbox_scroll = ListboxScroll(self.top)
listbox_scroll.grid(sticky="nsew", pady=PADY)
listbox_scroll.grid(sticky=tk.NSEW, pady=PADY)
self.listbox = listbox_scroll.listbox
self.listbox.bind("<<ListboxSelect>>", self.select)
session = self.app.core.session
@ -118,21 +118,21 @@ class HooksDialog(Dialog):
self.listbox.insert(tk.END, file)
frame = ttk.Frame(self.top)
frame.grid(sticky="ew")
frame.grid(sticky=tk.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", padx=PADX)
button.grid(row=0, column=0, sticky=tk.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=PADX)
self.edit_button.grid(row=0, column=1, sticky=tk.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=PADX)
self.delete_button.grid(row=0, column=2, sticky=tk.EW, padx=PADX)
button = ttk.Button(frame, text="Cancel", command=lambda: self.destroy())
button.grid(row=0, column=3, sticky="ew")
button.grid(row=0, column=3, sticky=tk.EW)
def click_create(self) -> None:
dialog = HookDialog(self, self.app)