Files
Phoenix/docs/sphinx/rest_substitutions/snippets/python/contrib/EvtHandler.Bind.1.py
Metallicow 1257f42189 ⁉️ Trim trailing whitespace docs/sphinx/rest_substitutions/*.py
⁉️ Not sure if the generated .rst stuff is intended to have
whitespace like this in it or not, so seperating this from the other
commits, so easy to revert if necessary.
2018-01-16 09:02:20 -06:00

37 lines
918 B
Python

##Andrea Gavana
#!/usr/bin/env python
# This sample shows a simple example of how to use the
# "Bind" method to handle an event
import wx
class MainWindow(wx.Frame):
def __init__(self, parent, title):
wx.Frame.__init__(self, parent, title=title)
# Bind the "close window" event to the OnClose handler
self.Bind(wx.EVT_CLOSE, self.OnClose)
self.Show()
def OnClose(self, event):
# This displays a message box asking the user to confirm
# she wants to quit the application
dlg = wx.MessageDialog(self, 'Are you sure you want to quit?', 'Question',
wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION)
if dlg.ShowModal() == wx.ID_YES:
self.Destroy()
else:
event.Veto()
app = wx.App(False)
frame = MainWindow(None, 'Bind example')
app.MainLoop()