Aesthetic improvements
authorJakob <jakob@jcornell.net>
Wed, 25 Dec 2019 04:01:24 +0000 (22:01 -0600)
committerJakob <jakob@jcornell.net>
Wed, 25 Dec 2019 04:01:24 +0000 (22:01 -0600)
main.py

diff --git a/main.py b/main.py
index 91e7c40c3130de57434d57d092b1eb727c39c401..2f007b725dfc1e4f258314b2eaac5c28bf9fe7d8 100644 (file)
--- 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)