From: Jakob Date: Wed, 25 Dec 2019 04:01:24 +0000 (-0600) Subject: Aesthetic improvements X-Git-Url: https://jcornell.net/gitweb/gitweb.cgi?a=commitdiff_plain;h=3ca5b40b66f9abc3d0e9590fbd185ef79fa3569f;p=tutoring-tool.git Aesthetic improvements --- diff --git a/main.py b/main.py index 91e7c40..2f007b7 100644 --- a/main.py +++ b/main.py @@ -16,6 +16,14 @@ from tkinter import ( TK_PAD = {'padx': 5, 'pady': 5} +def center_on_parent(child, parent): + center_x = int(parent.winfo_rootx() + parent.winfo_width() / 2) + center_y = int(parent.winfo_rooty() + parent.winfo_height() / 2) + child.update() + x = int(center_x - child.winfo_width() / 2) + y = int(center_y - child.winfo_height() / 2) + child.geometry('+{}+{}'.format(x, y)) + class Linkable: def on_linked(self): @@ -202,6 +210,7 @@ class MainView(View): def on_gen_plot(): dialog = tk.Toplevel(self.root) dialog.title("Generate plot") + dialog.minsize(250, 0) type_var = tk.StringVar(self.root) select_frame = tk.Frame(dialog) type_select = ttk.OptionMenu(select_frame, type_var) @@ -229,6 +238,7 @@ class MainView(View): type_select.pack(side = 'left', **TK_PAD) select_frame.pack(**TK_PAD) gen_btn.pack(**TK_PAD) + center_on_parent(dialog, self.root) self.gen_plot_btn = ttk.Button(actions_frame, text = "Generate plot", command = on_gen_plot) self.student_sel.pack(**TK_PAD, side = tk.LEFT)