From 3ca5b40b66f9abc3d0e9590fbd185ef79fa3569f Mon Sep 17 00:00:00 2001 From: Jakob Date: Tue, 24 Dec 2019 22:01:24 -0600 Subject: [PATCH] Aesthetic improvements --- main.py | 10 ++++++++++ 1 file changed, 10 insertions(+) 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) -- 2.30.2