Python弹出输入框并获取输入值的实例
作者:劲爆音乐网 时间:2021-04-05 00:49:10
使用自带的Tkinter模块,简单的弹输入框示例,返回输入值
from Tkinter import *
import tkMessageBox
def getInput(title, message):
def return_callback(event):
print('quit...')
root.quit()
def close_callback():
tkMessageBox.showinfo('message', 'no click...')
root = Tk(className=title)
root.wm_attributes('-topmost', 1)
screenwidth, screenheight = root.maxsize()
width = 300
height = 100
size = '%dx%d+%d+%d' % (width, height, (screenwidth - width)/2, (screenheight - height)/2)
root.geometry(size)
root.resizable(0, 0)
lable = Label(root, height=2)
lable['text'] = message
lable.pack()
entry = Entry(root)
entry.bind('<Return>', return_callback)
entry.pack()
entry.focus_set()
root.protocol("WM_DELETE_WINDOW", close_callback)
root.mainloop()
str = entry.get()
root.destroy()
return str
来源:https://blog.csdn.net/t60339/article/details/82842728
标签:Python,弹出,输入框,输入值
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
解决Python3.8用pip安装turtle-0.0.2出现错误问题
2021-04-07 03:51:20
![](https://img.aspxhome.com/file/2023/9/87939_0s.jpg)
Python3 log10()函数简单用法
2021-06-27 16:47:16
Python把图片转化为pdf代码实例
2021-04-05 19:06:36
详解Python打包分发工具setuptools
2022-10-18 02:53:13
![](https://img.aspxhome.com/file/2023/3/103713_0s.png)
使用CSS选择器创建个性化链接样式
2009-06-02 13:07:00
![](https://img.aspxhome.com/file/UploadPic/up/2009060213205633.gif)
Python简单实现阿拉伯数字和罗马数字的互相转换功能示例
2021-08-29 08:52:57
![](https://img.aspxhome.com/file/2023/4/79794_0s.png)
基于Python OpenCV实现图像的覆盖
2022-09-12 22:05:02
![](https://img.aspxhome.com/file/2023/2/99132_0s.jpg)
Python面向对象之多态原理与用法案例分析
2023-08-16 00:09:59
![](https://img.aspxhome.com/file/2023/7/81537_0s.png)
Python实例一个类背后发生了什么
2023-05-19 05:44:18
如何为Access数据库表添加日期或时间戳
2008-11-21 12:46:00
使用Python开发SQLite代理服务器的方法
2021-01-27 13:10:31
Python中的优先队列(priority queue)和堆(heap)
2023-11-22 05:40:03
![](https://img.aspxhome.com/file/2023/0/65900_0s.png)
Matplotlib绘制子图的常见几种方法
2022-04-04 06:19:47
![](https://img.aspxhome.com/file/2023/8/102338_0s.png)
Python Tkinter实现简易计算器功能
2023-08-08 09:53:30
![](https://img.aspxhome.com/file/2023/5/105795_0s.jpg)
如何在js中使用FileSystemObject(fso)
2007-09-23 09:10:00
基于Mediapipe+Opencv实现手势检测功能
2023-09-18 13:11:52
![](https://img.aspxhome.com/file/2023/8/114748_0s.png)
ASP常见的保留字整理(变量与表名注意不能用)
2013-06-01 19:58:01
浅谈python 四种数值类型(int,long,float,complex)
2023-12-17 05:26:48
python基础之reverse和reversed函数的介绍及使用
2022-10-19 19:12:18
Python的Bottle框架中返回静态文件和JSON对象的方法
2023-11-07 20:14:41
![](https://img.aspxhome.com/file/2023/4/66374_0s.png)