Detailed Explanation of GUI Label and Button Examples in python
- 2021-07-03 00:30:26
- OfStack
As shown below:
#coding=utf-8
import Tkinter
top=Tkinter.Tk()
#400x300 Represents the size of the main window at initialization, 300,100 Represent the initialization position of the window, respectively
#x: Is lowercase x
top.geometry('400x300+300+100')
# Create 1 A text box with the content of " hello world "
lab=Tkinter.Label(top,text='hello world')
# Layout mode
lab.pack()
# Create 1 Buttons
button=Tkinter.Button(top,text='quit',command=top.quit,bg='red',fg='orange')
#expand Set 1 Enable fill Attribute
#expand Set 0 Shut down fill Attribute
#fill=X When GUI When the form size changes, widget In X Direction following GUI Form change
#fill=Y When GUI When the form size changes, widget In Y Direction following GUI Form change
#fill=BOTH When GUI When the form size changes, widget In X , Y Two-direction following GUI Form change
button.pack(fill=Tkinter.X,expand=1)
# Event monitoring
Tkinter.mainloop()