优主张 2018-03-04
首发时间:2018-03-04 22:18




tkinter.messagebox.askquestion(消息框标题,提示内容)

tkinter.messagebox.askokcancel(消息框标题,提示内容)
是/否对话框【返回True False】:
重试/取消对话框:【返回值:True False】
<strong>tkinter.messagebox.askyesnocancel(标题,提示内容)</strong>
<strong>from tkinter import *
import tkinter.messagebox
def info_warn_err():
a=tkinter.messagebox.showinfo("我的标题","我的提示1")
print(a)
a=tkinter.messagebox.showwarning("我的标题","我的提示2")
print(a)
a=tkinter.messagebox.showerror("我的标题", "我的提示3")
print(a)
def func2():
a=tkinter.messagebox.askyesno("我的标题","我的提示1")
print(a)
a=tkinter.messagebox.askokcancel("我的标题","我的提示2")
print(a)
a=tkinter.messagebox.askquestion("我的标题","我的提示3")
print(a)
a=tkinter.messagebox.askretrycancel("我的标题","我的提示4")
print(a)
a=tkinter.messagebox.askyesnocancel("我的标题","我的提示5")
print(a)
#这里用作演示如何使用对话框
if tkinter.messagebox.askyesno("我的标题", "确认关闭窗口吗!"):
root.destroy()
root=Tk()
btn=Button(root,text="信息、警告、错误消息框",command=info_warn_err)
btn1=Button(root,text="对话框",command=func2)
btn.pack()
btn1.pack()
root.mainloop()</strong>
import tkinter.filedialog
from tkinter import *
def func1():
a=tkinter.filedialog.asksaveasfilename()#返回文件名
print(a)
a =tkinter.filedialog.asksaveasfile()#会创建文件
print(a)
a =tkinter.filedialog.askopenfilename()#返回文件名
print(a)
a =tkinter.filedialog.askopenfile()#返回文件流对象
print(a)
a =tkinter.filedialog.askdirectory()#返回目录名
print(a)
a =tkinter.filedialog.askopenfilenames()#可以返回多个文件名
print(a)
a =tkinter.filedialog.askopenfiles()#多个文件流对象
print(a)
root=Tk()
btn1=Button(root,text="click",command=func1)
btn1.pack()
root.mainloop()使用 CSS3,网页设计师可以使用他/她喜欢的任何字体。只需简单的将字体文件包含在网站中,它会自动下载给需要的用户。在新的 @font-face 规则中,您必须首先定义字体的名称,然后指向该字体文件。