O'Reilly logo

Tkinter GUI Application Development Blueprints - Second Edition by Bhaskar Chaudhary

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required