标签:can sky 多个 map tle mes 错误信息 窗口 打开文件
一、参数说明
| 语法 | 作用 | 截图 |
|---|---|---|
| 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()
标签:can sky 多个 map tle mes 错误信息 窗口 打开文件
原文地址:https://www.cnblogs.com/yang-2018/p/11793001.html