Skip to content

Instantly share code, notes, and snippets.

@EnriqueSoria
Last active April 20, 2018 07:22
Show Gist options
  • Save EnriqueSoria/0ffcc6421f806b8a26f3d4af80291fdd to your computer and use it in GitHub Desktop.
Save EnriqueSoria/0ffcc6421f806b8a26f3d4af80291fdd to your computer and use it in GitHub Desktop.
Tkinter skeleton
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