13.07.2015 Views

The wxPython tutorial

The wxPython tutorial

The wxPython tutorial

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>wxPython</strong> dialogshttp://www.zetcode.com/wxpython/dialogs/wx.YES_DEFAULTwx.NO_DEFAULTwx.ICON_EXCLAMATIONwx.ICON_ERRORwx.ICON_HANDwx.ICON_INFORMATIONwx.ICON_QUESTIONmake Yes button the defaultmake No button the defaultshow an alert iconshow an error iconsame as wx.ICON_ERRORshow an info iconshow a question icon#!/usr/bin/python# messages.pyimport wxclass Messages(wx.Frame):def __init__(self, parent, id, title):wx.Frame.__init__(self, parent, id, title, size=(250, 150))panel = wx.Panel(self, -1)hbox = wx.BoxSizer()sizer = wx.GridSizer(2, 2, 2, 2)btn1 = wx.Button(panel, -1, 'Info')btn2 = wx.Button(panel, -1, 'Error')btn3 = wx.Button(panel, -1, 'Question')btn4 = wx.Button(panel, -1, 'Alert')sizer.AddMany([btn1, btn2, btn3, btn4])hbox.Add(sizer, 0, wx.ALL, 15)panel.SetSizer(hbox)btn1.Bind(wx.EVT_BUTTON, self.ShowMessage1)btn2.Bind(wx.EVT_BUTTON, self.ShowMessage2)btn3.Bind(wx.EVT_BUTTON, self.ShowMessage3)btn4.Bind(wx.EVT_BUTTON, self.ShowMessage4)self.Centre()self.Show(True)def ShowMessage1(self, event):dial = wx.MessageDialog(None, 'Download completed', 'Info', wx.OK)dial.ShowModal()def ShowMessage2(self, event):dial = wx.MessageDialog(None, 'Error loading file', 'Error', wx.OK |wx.ICON_ERROR)dial.ShowModal()def ShowMessage3(self, event):dial = wx.MessageDialog(None, 'Are you sure to quit?', 'Question',wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION)dial.ShowModal()3 de 11 27/04/2008 1:04

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!