This article records the learning of Tkinter 8.6, the latest version of the GUI library (Tkinter).
It is assumed that Pycharm and Python have been installed. What is the installation status?
2.Reference
The following code will bring up the base window. It instantiates tkinter with your favorite name and runs it in .mainloop.
code
#tkinter library call
import tkinter as tk
#Instantiation of tkinter
pop = tk.Tk()
#
#Widget addition area
#
#.mainloop()Will display a window with.
pop.mainloop()
Result of execution
Widgets are parts such as buttons and labels. Let's write a process to display Hello World !! in the widget addition area.
code
import tkinter as tk
pop = tk.Tk()
#Hello World in the pop window!!I want to place the text.
label = tk.Label(pop,text="Hello World!!")
#.pack is a function that places objects.
label.pack()
pop.mainloop()
Result of execution
Was it displayed correctly? The contents so far are the basis of tkinter. From the next time, I will explain the widget and introduce the properties in several chapters.
Recommended Posts