码迷,mamicode.com
首页 > 编程语言 > 详细

wxPython:消息对话框MessageDialog

时间:2018-06-10 15:23:42      阅读:216      评论:0      收藏:0      [点我收藏+]

标签:can   dial   stay   box   apt   and   /usr   tab   sage   

  wxMessageDialog(wxWindowparentconst wxStringmessageconst wxStringcaption = "Message box"long style = wxOK | wxCANCELconst wxPointpos = 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_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 wx

class MyFrame(wx.Frame):
    
    def __init__(self, parent, id):
        wx.Frame.__init__(self, parent, id, u测试面板Panel, size = (600, 300))
        
        #创建面板
        panel = wx.Panel(self) 
        
        #在Panel上添加Button
        button = wx.Button(panel, label = u关闭, pos = (150, 60), size = (100, 60))
        
        #绑定单击事件
        self.Bind(wx.EVT_BUTTON, self.OnCloseMe, button)
        
    def OnCloseMe(self, event):
        dlg = wx.MessageDialog(None, u"消息对话框测试", u"标题信息", 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()

 

wxPython:消息对话框MessageDialog

标签:can   dial   stay   box   apt   and   /usr   tab   sage   

原文地址:https://www.cnblogs.com/fzuhyj/p/9162700.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!