Building the broad GUI structure

We start as usual by building the root window (7.01/view.py):

root = Tk()SCREEN_WIDTH = root.winfo_screenwidth()SCREEN_HEIGHT = root.winfo_screenheight()SCREEN_X_CENTER = (SCREEN_WIDTH - WINDOW_WIDTH) / 2SCREEN_Y_CENTER = (SCREEN_HEIGHT - WINDOW_HEIGHT) / 2root.geometry('%dx%d+%d+%d' % (WINDOW_WIDTH, WINDOW_HEIGHT, SCREEN_X_CENTER,  SCREEN_Y_CENTER))root.resizable(False, False)PianoTutor(root)root.mainloop()

We also create a new file named constants.py( 7.01), which currently holds the height parameters for the window.

We use two root window methods, root.winfo_screenwidth()and root_winfo_screenheight(), to obtain the screen width and height, respectively. We define two constants, WINDOW_WIDTH and WINDOW_HEIGHT ...

Get Tkinter GUI Application Development Blueprints - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.