日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程语言 > python >内容正文

python

python获取文本框里输入的值_如何从Tkinter文本框小工具获取输入?

發(fā)布時(shí)間:2023/12/15 python 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python获取文本框里输入的值_如何从Tkinter文本框小工具获取输入? 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

要從python 3中的文本框中獲取Tkinter輸入,我使用的完整學(xué)生級(jí)程序如下:

#Imports all (*) classes,

#atributes, and methods of tkinter into the

#current workspace

from tkinter import *

#***********************************

#Creates an instance of the class tkinter.Tk.

#This creates what is called the "root" window. By conventon,

#the root window in Tkinter is usually called "root",

#but you are free to call it by any other name.

root = Tk()

root.title('how to get text from textbox')

#**********************************

mystring = StringVar()

####define the function that the signup button will do

def getvalue():

## print(mystring.get())

#*************************************

Label(root, text="Text to get").grid(row=0, sticky=W) #label

Entry(root, textvariable = mystring).grid(row=0, column=1, sticky=E) #entry textbox

WSignUp = Button(root, text="print text", command=getvalue).grid(row=3, column=0, sticky=W) #button

############################################

# executes the mainloop (that is, the event loop) method of the root

# object. The mainloop method is what keeps the root window visible.

# If you remove the line, the window created will disappear

# immediately as the script stops running. This will happen so fast

# that you will not even see the window appearing on your screen.

# Keeping the mainloop running also lets you keep the

# program running until you press the close buton

root.mainloop()

總結(jié)

以上是生活随笔為你收集整理的python获取文本框里输入的值_如何从Tkinter文本框小工具获取输入?的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。