python TKinter method of getting the content of a text box
- 2020-12-10 00:45:13
- OfStack
As shown below:
#coding:utf-8
import urllib,urllib2
import Tkinter # The import TKinter The module
ytm=Tkinter.Tk() # create Tk object
ytm.title("login") # Set window title
ytm.geometry("300x300") # Set window size
l1=Tkinter.Label(ytm,text=" The user name ") # The label
l1.pack() # Specifies that the package manager places components
user_text=Tkinter.Entry() # Create text box
user_text.pack()
def getuser():
user=user_text.get() # Gets the text box content
print user
Tkinter.Button(ytm,text=" The login ",command=getuser).pack() #command Bind the method to get the text box content
ytm.mainloop() # Go into the main loop