首页 > 编程语言 > 详细

Python tkinter之弹窗messagebox

时间:2020-12-03 12:54:32      阅读:45      评论:0      收藏:0      [点我收藏+]

1、弹窗

# -*- encoding=utf-8 -*-
import tkinter
from tkinter import messagebox


def event():
    ret = messagebox.showinfo(提示信息, 你看我还有机会吗?)
    print(ret:{}.format(ret))
    ret = messagebox.showwarning(提示信息, 你看我还有机会吗?)
    print(ret:{}.format(ret))
    ret = messagebox.showerror(提示信息, 你看我还有机会吗?)
    print(ret:{}.format(ret))
    ret = messagebox.askyesno(提示信息, 你看我还有机会吗?)
    print(ret:{}.format(ret))
    ret = messagebox.askretrycancel(提示信息, 你看我还有机会吗?)
    print(ret:{}.format(ret))
    ret = messagebox.askquestion(提示信息, 你看我还有机会吗?)
    print(ret:{}.format(ret))
    ret = messagebox.askokcancel(提示信息, 你看我还有机会吗?)
    print(ret:{}.format(ret))
    ret = messagebox.askyesnocancel(提示信息, 你看我还有机会吗?)
    print(ret:{}.format(ret))


if __name__ == __main__:

    win = tkinter.Tk()  # 窗口
    win.title(南风丶轻语)  # 标题
    screenwidth = win.winfo_screenwidth()  # 屏幕宽度
    screenheight = win.winfo_screenheight()  # 屏幕高度
    width = 500
    height = 300
    x = int((screenwidth - width) / 2)
    y = int((screenheight - height) / 2)
    win.geometry({}x{}+{}+{}.format(width, height, x, y))  # 大小以及位置

    tkinter.Button(text=点击, command=event).pack()

    win.mainloop()

技术分享图片

 

Python tkinter之弹窗messagebox

原文:https://www.cnblogs.com/rainbow-tan/p/14077789.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!