Tkinter Create Window
In Tkinter, windows can be created using the following methods
from tkinter import *
root = Tk() # root is a custom Tk object name, you can also take other names
root.mainloop() # Put in the last line of the program
The window created using the Tk()
method is usually called the root window, after which you can create many controls in this root window, and you can also create upper-level windows in this root window. In this example, I use root as the object name, but readers can also choose other names. The above mainloop( ) method allows the program to continue to execute, while waiting and handling window events, click the "close" button at the top right of the window, the program will end.
Examples
Create a blank window with the default name tk.
from tkinter import *
root = Tk()
root.mainloop()
Output:
When the window appears, you can drag and drop to move the window or change the window size.
In GUI programming, sometimes the window created above is also called a container.