"""messagebox消息框"""
import tkinter as tk
#导入messagebox
import tkinter.messagebox as messagebox
window = tk.Tk()
window.title("My Window")
window.geometry("400x400")
var = tk.StringVar()
var.set("Hello world")
label = tk.Label(window,textvariable=var,font=("斜体",15),width=20,height=2,bg="black",fg="green")
label.pack()
def hit_me():
global label #使用全局变量
messagebox.showinfo(title="info",message="提示")
messagebox.showwarning(title="warning",message="警告")
messagebox.showerror(title="error",message="错误")
"""return yes or no"""
question = messagebox.askquestion(title="question",message="问题")
if question == "yes":
var.set("you selection yes")
else:
var.set("you selection no")
"""return True or False"""
askyesno = messagebox.askyesno(title="yes or no",message="选择")
if askyesno == True:
var.set("You selection True")
else:
var.set("You selection False")
"""return True or False"""
askokcancel = messagebox.askokcancel(title="cancel",message="取消")
if askokcancel == True:
var.set("You selection cancel")
else:
var.set("You don't selection cancel")
"""return True False None"""
result = messagebox.askyesnocancel(title="continue",message="Hello World")
if result == True:
var.set("You selection yes")
elif result == False:
var.set("You selection no")
elif result == None:
var.set("You selection cancel")
"""return True False"""
try_cancel = messagebox.askretrycancel(title="try_cancel",message="Hello World")
if try_cancel == True:
var.set("You selection retry")
else:
var.set("You selection cancel")
button = tk.Button(window,text="hit_me",command=hit_me,fg="red",bg="green")
button.pack()
window.mainloop()


python tkinter messagebox的更多相关文章

  1. Python的tkinter和tkinter.messagebox应用-鼠标和键盘命令绑定

    __author__ = 'Administrator' from tkinter import * import tkinter.messagebox class MainWindow: def b ...

  2. Python之tkinter.messagebox弹窗

    messagebox:tkinter的消息框.对话框 一.messagebox.showinfo(title='提示', message='错误') from tkinter import * fro ...

  3. Python基于tkinter.messagebox实现简易消息框、对话框

    库导入: import tkinter import tkinter.messagebox 有关提示框: tkinter.messagebox.showinfo(title=None, message ...

  4. 关不掉的小姐姐程序python tkinter实现 学习---打包教程

    首先,我们先准备两个.py文件,还要图片文件         代码//是我自己手写的,copy时记得删掉,不然有可能错误,比如中英文啥的    当然 一些语法的无问题就百度,都能给你答案 第一个.py ...

  5. Python Tkinter 学习成果:点歌软件music

    笔者工作业余时间也没什么爱好,社交圈子也小,主要娱乐就是背着自己带电瓶的卖唱音响到住地附近找个人多的位置唱唱KtV. 硬件上点歌就用笔记本电脑,歌曲都是网上下载的mkv格式的含有两个音轨的视频.因此点 ...

  6. Python Tkinter 学习历程 一

    一丶一个简单的程序 from tkinter import * #引入所有类#查看tk版本#tkinter._test() root = Tk(); #对这个类进行实例化 w1 = Label(roo ...

  7. python Tkinter之Button

    Button小部件是一个标准的Tkinter的部件,用于实现各种按钮.按钮可以包含文本或图像,您可以调用Python函数或方法用于每个按钮. Tkinter的按钮被按下时,会自动调用该函数或方法. 该 ...

  8. python tkinter module的用法

    tkinter windows下从python3.2版本之后是自动安装的. python3.3之后的引入方式: >>> import _tkinter>>> imp ...

  9. python gui tkinter快速入门教程 | python tkinter tutorial

    本文首发于个人博客https://kezunlin.me/post/d5c57f56/,欢迎阅读最新内容! python tkinter tutorial Guide main ui messageb ...

随机推荐

  1. SSM(SpringMVC Spring Mybatis)框架整合搭建

    1.新建一个web工程. 2.首先看一下整体的框架结构: 3.将ssm框架搭建所需要的jar包复制到lib目录下 3.需要配置各个配置文件. 1)配置web.xml文件: <?xml versi ...

  2. 【转】 为什么我们做分布式使用Redis

    绝大部分写业务的程序员,在实际开发中使用 Redis 的时候,只会 Set Value 和 Get Value 两个操作,对 Redis 整体缺乏一个认知.这里对 Redis 常见问题做一个总结,解决 ...

  3. element ui table单选框点击全选问题

    <template slot-scope="scope"> <el-radio-group v-model="scope.row.HandleState ...

  4. Exceptionless 生产部署笔记

    参考 部署用于生产的Exceptionlees(一个强大易用的日志收集服务) 1. 安装配置 redis 4.0  点击下载redis教学脑图 cd /opt wget http://download ...

  5. PHP利用模板消息无限制向用户推送消息

    <?php //获取微信access_token function getaccess_token(){ //appid与appsecret改成你自己的 $appid = '自己的appid'; ...

  6. BZOJ4451 [Cerc2015]Frightful Formula 多项式 FFT 递推 组合数学

    原文链接http://www.cnblogs.com/zhouzhendong/p/8820963.html 题目传送门 - BZOJ4451 题意 给你一个$n\times n$矩阵的第一行和第一列 ...

  7. 观察者模式(Observer)和发布(Publish/订阅模式(Subscribe)的区别

    观察者模式(Observer)和发布(Publish/订阅模式(Subscribe)的区别 在翻阅资料的时候,有人把观察者(Observer)模式等同于发布(Publish)/订阅(Subscribe ...

  8. CSS---通向臃肿的道路(关于 “separation of concerns” (SoC)的原则)

    When it comes to CSS, I believe that the sacred principle of “separation of concerns” (SoC) has lead ...

  9. 4.2模拟赛 wormhole(期望DP Dijkstra)

    \(\color{white}{orzmjt又切题了...}\) \(Description\) 给定一张有向图,每条边在每一时刻有\(p_i\)的概率存在.求最优策略下从\(1\)走到\(n\)最少 ...

  10. Python-Django学习

    1,安装Django与python版本的对应1.8 2.7,3.2--3.51.9,1.10 2.7,3.4,3.51.11 2.7,3.4,3.5,3.62.0 2.1 第一种安装:pip inst ...