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) / 2 SCREEN_Y_CENTER = (SCREEN_HEIGHT - WINDOW_HEIGHT) / 2 root.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
, and then place the window on the x, y center of the computer screen.
Notice the line root.resizable(False, False)
. This root window method takes two Boolean arguments to decide if the window is resizable in the x and y directions. Setting both...