import wx class MainFrame(wx.Frame): def __init__(self, parent): wx.Frame.__init__(self, parent, -1, 'Runnable example') btn = wx.Button(self, -1, 'Show example') self.Bind(wx.EVT_BUTTON, self.on_button, btn) hsizer = wx.BoxSizer(wx.HORIZONTAL) vsizer = wx.BoxSizer(wx.VERTICAL) hsizer.Add(btn, flag=wx.ALIGN_CENTER) vsizer.Add(hsizer, proportion=1, flag=wx.ALIGN_CENTER) self.SetSizer(vsizer) def on_button(self, event): # Show the progress dialog. pdlg = self.show_loading() # Close the progress dialog and show an error message. pdlg.Destroy() wx.MessageBox('There was an error\n\nError information...', 'Error', wx.OK | wx.ICON_ERROR, self) def show_loading(self): style = wx.PD_APP_MODAL | wx.PD_ELAPSED_TIME | wx.PD_REMAINING_TIME dialog = wx.ProgressDialog( 'Saving file', 'Your document is being saved\n\nPlease wait', parent=self, style=style ) dialog.Pulse() return dialog class App(wx.App): def OnInit(self): self.frame = MainFrame(None) self.SetTopWindow(self.frame) self.frame.Show(True) return True if __name__ == '__main__': app = App() app.MainLoop()