diff --git a/wx/lib/busy.py b/wx/lib/busy.py index 7041e71d..30fe06ed 100644 --- a/wx/lib/busy.py +++ b/wx/lib/busy.py @@ -1,6 +1,6 @@ #--------------------------------------------------------------------------- # File: busy.py -# Description: A class like wx.BusyInfo but which doesn't take up so much +# Description: A class like wx.BusyInfo but which doesn't take up so much # space by default and which has a nicer look. # # Date: 11-Sept-2012 @@ -25,26 +25,26 @@ class BusyInfo(object): size is smaller, (unless the size of the message requires a larger window size) and the background and foreground colors of the message box can be set. - + Creating an instace of the class witll create an show a window with the given message, and when the instance is deleted then that window will be closed. This class also implements the context manager magic methods, so it can be used with Python's `with` statement, like this:: - + with BusyInfo('Please wait...'): doSomethingThatNeedsWaiting() - + """ - + def __init__(self, msg, parent=None, bgColour=None, fgColour=None): """ Create a new :class:`BusyInfo`. - + :param string `msg`: a string to be displayed in the BusyInfo window. - :param Window `parent`: an optional window to be used as the parent of - the `:class:`BusyInfo`. If given then the BusyInfo will be centered + :param Window `parent`: an optional window to be used as the parent of + the `:class:`BusyInfo`. If given then the BusyInfo will be centered over that window, otherwise it will be centered on the screen. - :param Colour `bgColour`: colour to be used for the background + :param Colour `bgColour`: colour to be used for the background of the :class:`BusyInfo` :param Colour `fgColour`: colour to be used for the foreground (text) of the :class:`BusyInfo` @@ -53,10 +53,10 @@ class BusyInfo(object): self.frame.Show() self.frame.Refresh() self.frame.Update() - + def __del__(self): self.Close() - + def Close(self): """ Hide and close the busy info box. @@ -65,15 +65,15 @@ class BusyInfo(object): self.frame.Hide() self.frame.Close() self.frame = None - - - # Magic methods for using this class as a Context Manager + + + # Magic methods for using this class as a Context Manager def __enter__(self): return self def __exit__(self, exc_type, exc_val, exc_tb): self.Close() return False - + #--------------------------------------------------------------------------- @@ -86,12 +86,12 @@ class _InfoFrame(wx.Frame): panel = wx.Panel(self) text = StaticText(panel, -1, msg) - + for win in [panel, text]: win.SetCursor(wx.HOURGLASS_CURSOR) win.SetBackgroundColour(bgColour) win.SetForegroundColour(fgColour) - + size = text.GetBestSize() self.SetClientSize((size.width + 60, size.height + 40)) panel.SetSize(self.GetClientSize()) @@ -103,12 +103,12 @@ class _InfoFrame(wx.Frame): if __name__ == '__main__': - + def test1(frm): with BusyInfo("short message...", frm): wx.Sleep(2) wx.CallLater(1000, test2, frm) - + def test2(frm): with BusyInfo("This is my longer short message. Please be patient...", frm): wx.Sleep(2) @@ -119,14 +119,14 @@ if __name__ == '__main__': wx.Sleep(2) del busy wx.CallLater(1000, test4, frm) - + def test4(frm): with BusyInfo("Without using the parent window..."): wx.Sleep(2) wx.CallLater(1000, test5, frm) def test5(frm): - + message = """A long message with line breaks: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim @@ -137,12 +137,11 @@ cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.""" with BusyInfo(message, frm): wx.Sleep(2) - - - + + +if __name__ == '__main__': app = wx.App(False) frm = wx.Frame(None, title="BusyInfoTest") wx.CallLater(1000, test1, frm) frm.Show() app.MainLoop() - \ No newline at end of file