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):
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)
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)