zoukankan      html  css  js  c++  java
  • Tkinter 之MessageBox弹出框

    一、参数说明

    语法作用截图
    tk.messagebox.showwarning(title='提示', message='你确定要删除吗?') 警告信息弹窗  
    tk.messagebox.showinfo('提示','你确定要删除吗?') 提示信息弹窗  

     

    tk.messagebox.showerror('提示','你确定要删除吗?') 错误信息弹窗

    语法返回值作用
    tk.messagebox.askokcancel('提示','要执行此操作吗') True | False (疑问)确定取消对话框
    tk.messagebox.askquestion('提示', '要执行此操作吗') yes | no (疑问)是否对话框
    tk.messagebox.askyesno('提示', '要执行此操作吗') True | False (疑问)是否对话框
    tk.messagebox.askretrycancel('提示', '要执行此操作吗') True | False (警告)重试取消对话框
    语法返回值作用
    tk.filedialog.asksaveasfilename() 含后缀文件目录 另存为窗口弹窗。
    tk.filedialog.asksaveasfile() 文件流对象 另存为窗口弹窗,会创建文件。
    tkinter.filedialog.askopenfilename() 含后缀文件目录 打开文件弹窗。
    tk.filedialog.askopenfile() 文件流对象 打开文件弹窗,
    tk.filedialog.askdirectory() 目录名 选择文件弹窗
    tk.filedialog.askopenfilenames() 元组 打开多个文件名
    tk.filedialog.askopenfiles()# 列表 多个文件流对象

    二、代码示例

    import tkinter as tk
    import tkinter.messagebox
    import tkinter.filedialog
    
    window = tk.Tk()
    # 设置窗口大小
    winWidth = 600
    winHeight = 400
    # 获取屏幕分辨率
    screenWidth = window.winfo_screenwidth()
    screenHeight = window.winfo_screenheight()
    
    x = int((screenWidth - winWidth) / 2)
    y = int((screenHeight - winHeight) / 2)
    
    # 设置主窗口标题
    window.title("MessageBox参数说明")
    # 设置窗口初始位置在屏幕居中
    window.geometry("%sx%s+%s+%s" % (winWidth, winHeight, x, y))
    # 设置窗口图标
    window.iconbitmap("./image/icon.ico")
    # 设置窗口宽高固定
    window.resizable(0, 0)
    
    
    tk.messagebox.askokcancel("提示", "你确定要删除吗?")
    
    tk.messagebox.askquestion("提示", "你确定要删除吗?")
    
    tk.messagebox.askyesno("提示", "你确定要删除吗?")
    
    tk.messagebox.askretrycancel("提示", "你确定要删除吗?")
    
    
    tk.messagebox.showinfo("提示", "你确定要删除吗?")
    tk.messagebox.showwarning("提示", "你确定要删除吗?")
    tk.messagebox.showerror("提示", "你确定要删除吗?")
    
    # tk.filedialog.asksaveasfilename()
    
    
    window.mainloop()
    

      

  • 相关阅读:
    jQuery Mobile-jquery Mobile 怎么用ajax提交表单
    Passing data between pages in JQuery Mobile | Ram's Blog
    jQuery Mobile Docs
    jquery mobile header title左对齐 button右对齐
    jquery mobile -role
    jQueryMobile$(document).ready 等价于?( jQuery mobi...
    HTML5,jQuery Mobile 可视化生成器 Tiggzi
    WebApi系列~开放的CORS,跨域资源访问对所有人开放
    WebApi系列~目录
    WebApi系列~基于单请求封装多请求的设计~请求的安全性设计与实现
  • 原文地址:https://www.cnblogs.com/yang-2018/p/11793001.html
Copyright © 2011-2022 走看看