国产成人精品久久免费动漫-国产成人精品天堂-国产成人精品区在线观看-国产成人精品日本-a级毛片无码免费真人-a级毛片毛片免费观看久潮喷

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

python tkinter的消息框模塊(messagebox,simpledialog)

瀏覽:3日期:2022-07-06 08:56:14

tkinter提供了三個(gè)模塊,可以創(chuàng)建彈出對(duì)話窗口:(使用必須單獨(dú)導(dǎo)入模塊)

1.messagebox消息對(duì)話框

示例:askokcancel

python tkinter的消息框模塊(messagebox,simpledialog)

import tkinter# 導(dǎo)入消息對(duì)話框子模塊import tkinter.messagebox# 創(chuàng)建主窗口root = tkinter.Tk()# 設(shè)置窗口大小root.minsize(300,300)# 聲明函數(shù)def okqqq(): # 彈出對(duì)話框 result = tkinter.messagebox.askokcancel(title = ’標(biāo)題~’,message=’內(nèi)容:要吃飯嘛?’)# 返回值為True或者False print(result)# 添加按鈕btn1 = tkinter.Button(root,text = ’ok’,command = okqqq)btn1.pack()# 加入消息循環(huán)root.mainloop()

示例:askquestion

python tkinter的消息框模塊(messagebox,simpledialog)

import tkinter# 導(dǎo)入消息對(duì)話框子模塊import tkinter.messagebox# 創(chuàng)建主窗口root = tkinter.Tk()# 設(shè)置窗口大小root.minsize(300,300)# 聲明函數(shù)def question(): # 彈出對(duì)話框 result = tkinter.messagebox.askquestion(title = ’標(biāo)題’,message=’內(nèi)容:你吃飯了嘛?’) # 返回值為:yes/no print(result)# 添加按鈕btn1 = tkinter.Button(root,text = ’question’,command = question)btn1.pack()# 加入消息循環(huán)root.mainloop()

示例:askretrycancel(重試)

python tkinter的消息框模塊(messagebox,simpledialog)

import tkinter# 導(dǎo)入消息對(duì)話框子模塊import tkinter.messagebox# 創(chuàng)建主窗口root = tkinter.Tk()# 設(shè)置窗口大小root.minsize(300,300)# 聲明函數(shù)def retry(): # 彈出對(duì)話框 result = tkinter.messagebox.askretrycancel(title = ’標(biāo)題’,message=’內(nèi)容:女生拒絕了你?。俊? # 返回值為:True或者False print(result)# 添加按鈕btn1 = tkinter.Button(root,text = ’retry’,command = retry)btn1.pack()# 加入消息循環(huán)root.mainloop()

示例:askyesno

python tkinter的消息框模塊(messagebox,simpledialog)

# 聲明函數(shù)def yesno(): # 彈出對(duì)話框 result = tkinter.messagebox.askyesno(title = ’標(biāo)題’,message=’內(nèi)容:你喜歡我嗎?’) # 返回值為:True或者False print(result)# 添加按鈕btn1 = tkinter.Button(root,text = ’yesno’,command = yesno)btn1.pack()

示例:showerror (出錯(cuò))

python tkinter的消息框模塊(messagebox,simpledialog)

# 聲明函數(shù)def error(): # 彈出對(duì)話框 result = tkinter.messagebox.showerror(title = ’出錯(cuò)了!’,message=’內(nèi)容:你的年齡不符合要求。’) # 返回值為:ok print(result)# 添加按鈕btn1 = tkinter.Button(root,text = ’error’,command = error)btn1.pack()

示例:showwarning(警告)

python tkinter的消息框模塊(messagebox,simpledialog)

# 聲明函數(shù)def warning(): # 彈出對(duì)話框 result = tkinter.messagebox.showwarning(title = ’出錯(cuò)了!’,message=’內(nèi)容:十八歲以下禁止進(jìn)入?!? # 返回值為:ok print(result)# 添加按鈕btn1 = tkinter.Button(root,text = ’warning’,command = warning)btn1.pack()

示例:showinto (信息提示)

python tkinter的消息框模塊(messagebox,simpledialog)

# 聲明函數(shù)def info(): # 彈出對(duì)話框 result = tkinter.messagebox.showinfo(title = ’信息提示!’,message=’內(nèi)容:您的女朋友收到一只不明來(lái)歷的口紅!’) # 返回值為:ok print(result)# 添加按鈕btn1 = tkinter.Button(root,text = ’info’,command = info)btn1.pack()

2.simpledialog簡(jiǎn)單信息對(duì)話框

示例:asksting(獲取字符串)

python tkinter的消息框模塊(messagebox,simpledialog)

import tkinter# 導(dǎo)入子模塊import tkinter.simpledialog# 創(chuàng)建主窗口root = tkinter.Tk()# 設(shè)置窗口大小root.minsize(300,300)# 創(chuàng)建函數(shù)def askname(): # 獲取字符串(標(biāo)題,提示,初始值) result = tkinter.simpledialog.askstring(title = ’獲取信息’,prompt=’請(qǐng)輸入姓名:’,initialvalue = ’可以設(shè)置初始值’) # 打印內(nèi)容 print(result)# 添加按鈕btn = tkinter.Button(root,text = ’獲取用戶名’,command = askname)btn.pack()# 加入消息循環(huán)root.mainloop()

示例:askinteger(獲取整型)

python tkinter的消息框模塊(messagebox,simpledialog)

import tkinter# 導(dǎo)入消息對(duì)話框子模塊import tkinter.simpledialog# 創(chuàng)建主窗口root = tkinter.Tk()# 設(shè)置窗口大小root.minsize(300,300)# 創(chuàng)建函數(shù)def askage(): # 獲取整型(標(biāo)題,提示,初始值) result = tkinter.simpledialog.askinteger(title = ’獲取信息’,prompt=’請(qǐng)輸入年齡:’,initialvalue = ’18’) # 打印內(nèi)容 print(result)# 添加按鈕btn = tkinter.Button(root,text = ’獲取年齡’,command = askage)btn.pack()# 加入消息循環(huán)root.mainloop()

示例:askfloat(獲取浮點(diǎn)型)

python tkinter的消息框模塊(messagebox,simpledialog)

import tkinter# 導(dǎo)入消息對(duì)話框子模塊import tkinter.simpledialog# 創(chuàng)建主窗口root = tkinter.Tk()# 設(shè)置窗口大小root.minsize(300,300)# 創(chuàng)建函數(shù)def askheight(): # 獲取浮點(diǎn)型數(shù)據(jù)(標(biāo)題,提示,初始值) result = tkinter.simpledialog.askfloat(title = ’獲取信息’,prompt=’請(qǐng)輸入身高(單位:米):’,initialvalue = ’18.0’) # 打印內(nèi)容 print(result)# 添加按鈕btn = tkinter.Button(root,text = ’獲取身高’,command = askheight)btn.pack()# 加入消息循環(huán)root.mainloop()

以上就是python tkinter的消息框模塊的詳細(xì)內(nèi)容,更多關(guān)于python tkinter消息框的資料請(qǐng)關(guān)注好吧啦網(wǎng)其它相關(guān)文章!

標(biāo)簽: Python 編程
主站蜘蛛池模板: 欧美性aaa | 一区二区三区四区在线 | 亚洲一级毛片在线播放 | 一本久 | 亚洲高清在线观看视频 | 那种视频在线观看 | 欧美视频精品 | 看黄网址| 国产一级做a爰片在线 | 国产在线91精品入口首页 | aaa级大片| 一本综合久久国产二区 | 久草视频国产 | 国产视频网站在线观看 | 成人免费毛片网站 | 日韩欧美一级 | 性欧美成人依依影院 | 精品国产亚洲一区二区三区 | 91久久亚洲精品国产一区二区 | 步兵一区二区三区在线观看 | 久久精品国产精品青草 | 高清波多野结衣一区二区三区 | 欧美精品99久久久久久人 | 性高湖久久久久久久久 | 最近日本免费观看视频 | 午夜性刺激免费视频 | 国产精品三级手机在线观看 | 亚洲aⅴ| 欧美成人自拍视频 | 99久久精品费精品国产一区二 | xxxxfreexxxx人妖| 亚洲综合久久久久久888 | 5x社区直接进入一区二区三区 | 国产成人tv在线观看 | 亚洲男人天堂手机版 | 男女男免费视频网站国产 | 欧美激情久久久久久久大片 | 国产成人精品亚洲日本在线观看 | 日韩乱码中文字幕视频 | 亚洲欧美视频一区二区三区 | 中文字幕在线观看日韩 |