Proper use of wx.BusyCursor

The c++ docs say to create a wxBusyCursor on the stack and let the automatic destructor take care of getting rid of it. Do I need to call __del__ in wxPython or can I just...

def MyFunction():
   bc = wx.BusyCursor()
   DoSomething()
   # Let 'bc' go out of scope

Thanks,
Michael

Just letting it go out of scope won't always work as you expect. The garabge collector (gc) is free to delete the bc object whenever it wants to, so you may end up with a busy cursor longer than you want to. So I'd add a

del bc

at the end of the function.

-Matthias

···

Am Tue, 30 Aug 2005 08:53:33 -0500 hat Michael Hipp <Michael@Hipp.com> geschrieben:

The c++ docs say to create a wxBusyCursor on the stack and let the automatic destructor take care of getting rid of it. Do I need to call __del__ in wxPython or can I just...

def MyFunction():
   bc = wx.BusyCursor()
   DoSomething()
   # Let 'bc' go out of scope

Thanks,
Michael

Hi Michael,

I do this:

wx.BeginBusyCursor()
DoSomething()
wx.EndBusyCursor()

See you
Werner

Michael Hipp wrote:

···

The c++ docs say to create a wxBusyCursor on the stack and let the automatic destructor take care of getting rid of it. Do I need to call __del__ in wxPython or can I just...

def MyFunction():
  bc = wx.BusyCursor()
  DoSomething()
  # Let 'bc' go out of scope

Thanks,
Michael

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Tuesday, August 30, 2005, 10:53:33 AM, Michael Hipp wrote:

The c++ docs say to create a wxBusyCursor on the stack and let the automatic
destructor take care of getting rid of it. Do I need to call __del__ in
wxPython or can I just...

def MyFunction():
   bc = wx.BusyCursor()
   DoSomething()
   # Let 'bc' go out of scope

Or you could simply use wx.BeginBusyCursor() and wx.EndBusyCursor()
instead.

-- tacao

No bits were harmed during the making of this e-mail.

Werner F. Bruhin wrote:

Hi Michael,

I do this:

wx.BeginBusyCursor()
DoSomething()
wx.EndBusyCursor()

I wrote a little decorator to do the same..

def ShowBusyCursor(f):
    def func(*args, **kwargs):
        wx.BeginBusyCursor()
        ret = f(*args, **kwargs)
        wx.EndBusyCursor()
        return ret
    return func

@ShowBusyCursor
def DoSomething(self):
    # Doing something that takes a while

Will McGugan

···

--