Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def show_loading(parent, title, message=None, maximum=100):
- if not message:
- message = title
- # A class for the return value.
- class LoadingObject(object):
- def __init__(self, dialog):
- self.dialog = dialog
- self.is_done = False
- def done(self):
- if not self.is_done:
- self.dialog.Destroy()
- self.is_done = True
- def pulse(self, message):
- self.dialog.Pulse(message)
- def progress(self, current, message=None):
- if current >= maximum:
- current = current - 1
- if message is not None:
- self.dialog.Update(current, message)
- else:
- self.dialog.Update(current)
- # Create the progress dialog.
- dlg_style = wx.PD_APP_MODAL | wx.PD_ELAPSED_TIME | wx.PD_REMAINING_TIME
- dlg = wx.ProgressDialog(
- title, message, parent=parent, style=dlg_style, maximum=maximum
- )
- dlg.Pulse()
- # Return an instance of the LoadingDialog with the progress dialog attached.
- return LoadingObject(dlg)
Advertisement
Add Comment
Please, Sign In to add comment