Last active
April 20, 2018 07:22
-
-
Save EnriqueSoria/0ffcc6421f806b8a26f3d4af80291fdd to your computer and use it in GitHub Desktop.
Tkinter skeleton
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tkinter import Tk, Label, Button | |
class Main: | |
APP_NAME = '' | |
def __init__(self, master): | |
self.master = master | |
master.title(self.APP_NAME) | |
self.center(master) | |
def center(self, toplevel): | |
toplevel.update_idletasks() | |
w = toplevel.winfo_screenwidth() | |
h = toplevel.winfo_screenheight() | |
size = tuple(int(_) for _ in toplevel.geometry().split('+')[0].split('x')) | |
x = w/2 - size[0]/2 | |
y = h/2 - size[1]/2 | |
toplevel.geometry("%dx%d+%d+%d" % (size + (x, y))) | |
root = Tk() | |
root.geometry("600x500") | |
my_gui = Main(root) | |
root.mainloop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment