本文实例讲述了Python wxPython库消息对话框MessageDialog用法。分享给大家供大家参考,具体如下:
消息对话框即我们平时说的Messagebox,看看它的原型,下面是wxWidgets中的原型定义,C++风格,与python风格的区别就是wx前缀与后面名称直接相连,例如wxMessageDialog,在wxpython中使用时就是wx.MessageDialog
wxMessageDialog(wxWindow* parent, const wxString& message, const wxString& caption = "Message box", long style = wxOK | wxCANCEL, const wxPoint& pos = wxDefaultPosition)
其各参数不多做介绍,主要看看ShowModal()方法,它使用应用程序在对话框关闭前不能响应其它窗口的用户事件,返回一个整数,取值如下:
wx.ID_YES, wx.ID_NO,wx.ID_CANCEL, wx.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_DEFAUL