| 107 | |
| 108 | # Reference: https://stackoverflow.com/a/10018670 |
| 109 | def center(window): |
| 110 | window.update_idletasks() |
| 111 | width = window.winfo_width() |
| 112 | frm_width = window.winfo_rootx() - window.winfo_x() |
| 113 | win_width = width + 2 * frm_width |
| 114 | height = window.winfo_height() |
| 115 | titlebar_height = window.winfo_rooty() - window.winfo_y() |
| 116 | win_height = height + titlebar_height + frm_width |
| 117 | x = window.winfo_screenwidth() // 2 - win_width // 2 |
| 118 | y = window.winfo_screenheight() // 2 - win_height // 2 |
| 119 | window.geometry('{}x{}+{}+{}'.format(width, height, x, y)) |
| 120 | window.deiconify() |
| 121 | |
| 122 | def onKeyPress(event): |
| 123 | global line |