博客
关于我
Python GUI tkinter库 自学21
阅读量:280 次
发布时间:2019-03-01

本文共 871 字,大约阅读时间需要 2 分钟。

简单对话框与通用消息框的使用示例

简单对话框

  • title表示窗口标题
  • prompt是提示信息
  • kw为命名参数,可设置各种选项
  • initialvalue为初始值
  • minvalue为最小值
  • maxvalue为最大值
函数名 说明
askfloat(title, prompt, **kw) 用于获取浮点数输入
askinteger(title, prompt, **kw) 用于获取整数输入
askstring(title, prompt, **kw) 用于获取字符串输入
示例代码:
from tkinter.simpledialog import * window = Tk() window.geometry("500x200")

def test1():a = askinteger(title="输入年龄", prompt="请输入年龄", initialvalue=18, minvalue=1, maxvalue=150)show["text"] = a

Button(window, text="你多大了?", command=test1).pack()show = Label(window, width=10, height=5, bg="green")show.pack()

window.mainloop()

通用消息框

示例代码:
from tkinter import * from tkinter.messagebox import *

window = Tk()window.geometry("500x200")

a = showinfo(title="学习", message="你会成功的!")print(a)

window.mainloop()

ttk子模块(简要介绍)

以上代码示例展示了如何在Tkinter应用程序中使用简单对话框和通用消息框功能。通过合理配置参数,开发者可以根据需求实现多种用户交互场景。此外,Tkinter的ttk子模块提供了丰富的组件和布局选项,能够进一步提升应用程序的用户体验。

转载地址:http://zkho.baihongyu.com/

你可能感兴趣的文章
No mapping found for HTTP request with URI [/...] in DispatcherServlet with name ...的解决方法
查看>>
No mapping found for HTTP request with URI [/logout.do] in DispatcherServlet with name 'springmvc'
查看>>
No module named 'crispy_forms'等使用pycharm开发
查看>>
No module named cv2
查看>>
No module named tensorboard.main在安装tensorboardX的时候遇到的问题
查看>>
No module named ‘MySQLdb‘错误解决No module named ‘MySQLdb‘错误解决
查看>>
No new migrations found. Your system is up-to-date.
查看>>
No qualifying bean of type XXX found for dependency XXX.
查看>>
No resource identifier found for attribute 'srcCompat' in package的解决办法
查看>>
no session found for current thread
查看>>
No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android
查看>>
NO.23 ZenTaoPHP目录结构
查看>>
NO32 网络层次及OSI7层模型--TCP三次握手四次断开--子网划分
查看>>
NoClassDefFoundError: org/springframework/boot/context/properties/ConfigurationBeanFactoryMetadata
查看>>
Node JS: < 一> 初识Node JS
查看>>
Node-RED中使用JSON数据建立web网站
查看>>
Node-RED中使用json节点解析JSON数据
查看>>
Node-RED中使用node-random节点来实现随机数在折线图中显示
查看>>
Node-RED中使用node-red-browser-utils节点实现选择Windows操作系统中的文件并实现图片预览
查看>>
Node-RED中使用node-red-node-ui-iframe节点实现内嵌iframe访问其他网站的效果
查看>>