We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Window

Let's just get a graphical window up and running. When we run our code, it should open a new window with a blank canvas that our program can then draw on.

Assignment

  1. Start by importing a few things from tkinter:
from tkinter import Tk, BOTH, Canvas
    • Note: Tkinter is not a reactive framework like React or Vue - we need to tell the window when it should render to visuals.
    • Use the root widget's update_idletasks() and update() methods to accomplish this.
self.__root = Tk()
...
self.__root.protocol("WM_DELETE_WINDOW", self.close)
win = Window(800, 600)
win.wait_for_close()