国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

Python wxPython庫消息對話框MessageDialog用法示例

2020-01-04 14:35:47
字體:
供稿:網(wǎng)友

本文實例講述了Python wxPython庫消息對話框MessageDialog用法。分享給大家供大家參考,具體如下:

消息對話框即我們平時說的Messagebox,看看它的原型,下面是wxWidgets中的原型定義,C++風(fēng)格,與python風(fēng)格的區(qū)別就是wx前綴與后面名稱直接相連,例如wxMessageDialog,在wxpython中使用時就是wx.MessageDialog

wxMessageDialog(wxWindow* parent, const wxString& message, const wxString& caption = "Message box", long style = wxOK | wxCANCEL, const wxPoint& pos = wxDefaultPosition)

其各參數(shù)不多做介紹,主要看看ShowModal()方法,它使用應(yīng)用程序在對話框關(guān)閉前不能響應(yīng)其它窗口的用戶事件,返回一個整數(shù),取值如下:

wx.ID_YESwx.ID_NO, wx.ID_CANCELwx.ID_OK

另外,style的取值主要有以下幾種:

 

wxOK Show an OK button.
wxCANCEL Show a Cancel button.
wxYES_NO Show Yes and No buttons.
wxYES_DEFAULT Used with wxYES_NO, makes Yes button the default - which is the default behaviour.
wxNO_DEFAULT Used with wxYES_NO, makes No button the default.
wxICON_EXCLAMATION Shows an exclamation mark icon.
wxICON_HAND Shows an error icon.
wxICON_ERROR Shows an error icon - the same as wxICON_HAND.
wxICON_QUESTION Shows a question mark icon.
wxICON_INFORMATION Shows an information (i) icon.
wxSTAY_ON_TOP The message box stays on top of all other window, even those of the other applications (Windows only).

 

還是看一個例子:

代碼:

#!/usr/bin/env python# -*- coding: utf-8 -*-import wxclass MyFrame(wx.Frame): def __init__(self, parent, id):  wx.Frame.__init__(self, parent, id, u'測試面板Panel', size = (600, 300))  #創(chuàng)建面板  panel = wx.Panel(self)  #在Panel上添加Button  button = wx.Button(panel, label = u'關(guān)閉', pos = (150, 60), size = (100, 60))  #綁定單擊事件  self.Bind(wx.EVT_BUTTON, self.OnCloseMe, button) def OnCloseMe(self, event):  dlg = wx.MessageDialog(None, u"消息對話框測試", u"標(biāo)題信息", wx.YES_NO | wx.ICON_QUESTION)  if dlg.ShowModal() == wx.ID_YES:   self.Close(True)  dlg.Destroy()if __name__ == '__main__': app = wx.PySimpleApp() frame = MyFrame(parent = None, id = -1) frame.Show() app.MainLoop()

測試:

Python,wxPython,消息對話框,MessageDialog

希望本文所述對大家Python程序設(shè)計有所幫助。


注:相關(guān)教程知識閱讀請移步到python教程頻道。
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 饶阳县| 石家庄市| 潢川县| 巴里| 琼中| 彩票| 宜黄县| 隆尧县| 瓮安县| 习水县| 乐清市| 永年县| 齐河县| 水城县| 溧水县| 阿城市| 江都市| 濉溪县| 靖安县| 莆田市| 闻喜县| 同仁县| 铜鼓县| 东兰县| 富源县| 沙湾县| 左贡县| 嘉禾县| 益阳市| 涡阳县| 蚌埠市| 湟源县| 德钦县| 太和县| 同江市| 昌邑市| 开鲁县| 民勤县| 特克斯县| 玉环县| 绩溪县|