Setting a busy cursor, and then switching it off again

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

Setting a busy cursor, and then switching it off again

Donn Ingle
Hiya,
I want my app to show a "BUSY" cursor when a click event fires.

LEFT_UP fires, calls somefunc()

def somefunc()
A. wx.SetCursor ( wx.StockCursor ( wx.CURSOR_WAIT ) )
B. Do long loop
C. wx.SetCursor ( wx.StockCursor ( wx.CURSOR_ARROW ) )

What I find at the moment is:
A without C (i.e. delete line C) will show the busy cursor.
A with C will only show an arrow.

I have set various controls to use a certain cursor. For example I have two
list controls that I want to use a HAND cursor for.
Fine, a self.SetCursor ... does the job.

In attempting to reset from the busy cursor in somefunc(), I do a
wx.SetCursor back to the ARROW again, in another routine that does general
gui updating, after somefunc has exited, but now the list controls no
longer show a hand. Everything is stuck on an arrow.

Is there a way to temporarily show a BUSY cursor and then revert back to
whatever the various controls have been set to show by default ?


/d





Reply | Threaded
Open this post in threaded view
|

RE: Setting a busy cursor, and then switching it off again

Suzuki Alex
Donn,

You might want to look at wx.BeginBusyCursor() and wx.EndBusyCursor().

cheers, Alex

> -----Original Message-----
> From: news [mailto:[hidden email]]On Behalf Of Donn Ingle
> Sent: Thursday, November 30, 2006 12:00 PM
> To: [hidden email]
> Subject: [wxPython-users] Setting a busy cursor, and then switching it
> off again
>
>
> Hiya,
> I want my app to show a "BUSY" cursor when a click event fires.
>
> LEFT_UP fires, calls somefunc()
>
> def somefunc()
> A. wx.SetCursor ( wx.StockCursor ( wx.CURSOR_WAIT ) )
> B. Do long loop
> C. wx.SetCursor ( wx.StockCursor ( wx.CURSOR_ARROW ) )
>
> What I find at the moment is:
> A without C (i.e. delete line C) will show the busy cursor.
> A with C will only show an arrow.
>
> I have set various controls to use a certain cursor. For
> example I have two
> list controls that I want to use a HAND cursor for.
> Fine, a self.SetCursor ... does the job.
>
> In attempting to reset from the busy cursor in somefunc(), I do a
> wx.SetCursor back to the ARROW again, in another routine that
> does general
> gui updating, after somefunc has exited, but now the list controls no
> longer show a hand. Everything is stuck on an arrow.
>
> Is there a way to temporarily show a BUSY cursor and then
> revert back to
> whatever the various controls have been set to show by default ?
>
>
> /d
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail:
> [hidden email]
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Setting a busy cursor, and then switching it off again

Christian K.
In reply to this post by Donn Ingle
Donn Ingle <donn.ingle <at> gmail.com> writes:

>
> Hiya,
> I want my app to show a "BUSY" cursor when a click event fires.
>
> LEFT_UP fires, calls somefunc()
>
> def somefunc()
> A. wx.SetCursor ( wx.StockCursor ( wx.CURSOR_WAIT ) )
> B. Do long loop
> C. wx.SetCursor ( wx.StockCursor ( wx.CURSOR_ARROW ) )

It looks like that you're not allowing app to return to its MainLoop while
running somefunc, or are you working with threads in stpe B?. In that case you
should call wx.Yield() between A. and C. or even better several times while
excuting the long loop. If not your app will freeze.

Are you beware of wx.Begin/EndBusyCursor ?
http://wxwidgets.org/manuals/2.6.3/wx_dialogfunctions.html#wxbeginbusycursor

Christian




Reply | Threaded
Open this post in threaded view
|

RE: Setting a busy cursor, and then switching it off again

Donn Ingle
In reply to this post by Suzuki Alex
> wx.BeginBusyCursor()
Alex - where the heck do you guys get these oddball functions :)
I love it, problem solved!

wxPython.DanceOfJoy ( )
/d




Reply | Threaded
Open this post in threaded view
|

Re: RE: Setting a busy cursor, and then switching it off again

Werner F. Bruhin
Hi Donn,

Donn Ingle wrote:
>> wx.BeginBusyCursor()
>>    
> Alex - where the heck do you guys get these oddball functions :)
>  
Ctrl-H enter "cursor" and they are the two top suggestions - I guess you
know that this is in Boa :-)
> I love it, problem solved!
>
> wxPython.DanceOfJoy ( )
>  
Had no look on this one ;-)
Werner

> /d
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
>
>
>  




Reply | Threaded
Open this post in threaded view
|

Re: RE: Setting a busy cursor, and then switching it off again

nitro-4
In reply to this post by Donn Ingle
Am 30.11.2006, 12:09 Uhr, schrieb Donn Ingle <[hidden email]>:

>> wx.BeginBusyCursor()
> Alex - where the heck do you guys get these oddball functions :)
> I love it, problem solved!
>
> wxPython.DanceOfJoy ( )

You should really upgrade to the new wx namespace.


Reply | Threaded
Open this post in threaded view
|

Re: Setting a busy cursor, and then switching it off again

Don Dwiggins-2
In reply to this post by Suzuki Alex
Suzuki Alex wrote:
> Donn,
>
> You might want to look at wx.BeginBusyCursor() and wx.EndBusyCursor().

If you're working in the context of a single method, you can also create
an instance of wx.BusyCursor, assign it to a local variable, and forget
it.  The cursor will be changed back when the variable goes out of scope.

--
Don Dwiggins
Advanced Publishing Technology



Reply | Threaded
Open this post in threaded view
|

Re: Re: Setting a busy cursor, and then switching it off again

Chris Mellon
On 11/30/06, Don Dwiggins <[hidden email]> wrote:
> Suzuki Alex wrote:
> > Donn,
> >
> > You might want to look at wx.BeginBusyCursor() and wx.EndBusyCursor().
>
> If you're working in the context of a single method, you can also create
> an instance of wx.BusyCursor, assign it to a local variable, and forget
> it.  The cursor will be changed back when the variable goes out of scope.
>

This is not quite correct and not something to be generally relied on
- it will be changed back when the object is deleted, and it's not
guaranteed to happen just when you leave the scope.

It'd be just the work of a couple seconds to implement it as a context
manager for the with statement introduced in 2.5, though.

> --
> Don Dwiggins
> Advanced Publishing Technology
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Re: Setting a busy cursor, and then switching it off again

Donn Ingle
> It'd be just the work of a couple seconds to implement it as a context
> manager for the with statement introduced in 2.5, though.
Not familiar with that, can you give an example using the
wx.BeginBusyCursor ?

/d



Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Setting a busy cursor, and then switching it off again

Dj Gilcrease
def someMethod(self):
    wx.BeginBusyCursor()
    #Some code that does something, and may take a while to finish
    wx.EndBusyCursor()


Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Setting a busy cursor, and then switching it off again

Donn Ingle
> def someMethod(self):
>     wx.BeginBusyCursor()
>     #Some code that does something, and may take a while to finish
>     wx.EndBusyCursor()
DJ - I did get that after the first post, thanks.
I was asking Chris about his reference to the new "with" statement.

/d



Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Re: Setting a busy cursor, and then switching it off again

Chris Mellon
On 12/1/06, Donn Ingle <[hidden email]> wrote:
> > def someMethod(self):
> >     wx.BeginBusyCursor()
> >     #Some code that does something, and may take a while to finish
> >     wx.EndBusyCursor()
> DJ - I did get that after the first post, thanks.
> I was asking Chris about his reference to the new "with" statement.
>

>>> class BusyCursor():
...     def __enter__(self):
...         wx.BeginBusyCursor()
...     def __exit__(self, exc_type, exc_value, traceback):
...         wx.EndBusyCursor()

>>> import time
>>> from __future__ import with_statement
>>> with BusyCursor():
...     time.sleep(4)


> /d
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Re: Setting a busy cursor, and then switching it off again

Donn Ingle
>>>> class BusyCursor():
> ...     def __enter__(self):
> ...         wx.BeginBusyCursor()
> ...     def __exit__(self, exc_type, exc_value, traceback):
> ...         wx.EndBusyCursor()
>
>>>> import time
>>>> from __future__ import with_statement
>>>> with BusyCursor():
> ...     time.sleep(4)

Thanks. That ... bears some looking into :)
I'm guessing it's not VB's with statement!

/d