cursor_wait waiting for a result

Hi all.
I’ve a send/receive function that send a packet and wait for response.
i have a function like

self.sender.send(hostto,packet)
#self.view.SetCursor(wx.StockCursor(wx.CURSOR_WAIT)) #self.view is a wx.Frame
#Receive response from agent
(response,hostfrom)=self.receiver.receive(None)

As you can see i would that while i’m waiting for request i see the cursorWait.

Uncommenting my code that doesn’t work

How can i do?

···


Sbaush

Hi all.
I've a send/receive function that send a packet and wait for response.
i have a function like

self.sender.send(hostto,packet)
#self.view.SetCursor(wx.StockCursor(wx.CURSOR_WAIT)) #self.view is a

wx.Frame

#Receive response from agent
(response,hostfrom)=self.receiver.receive(None)

As you can see i would that while i'm waiting for request i see the

cursorWait.

Uncommenting my code that doesn't work

How can i do?

--
Sbaush

I assume that sender.send and receiver.receive are running in a separate
thread from wx.MainLoop() - if not, they should be!

You want SetCursor to be executed from within wx.MainLoop(), so it must be
called using wx.CallAfter(). Something like -

  wx.CallAfter(self.view.SetCursor,wx.StockCursor(wx.CURSOR_WAIT))

I *think* I have got the commas and brackets right, but you may have to
experiment.

HTH

Frank Millman

···

From: Sbaush [mailto:sbaush@gmail.com]
Sent: 14 February 2006 03:06 AM
To: wxPython-users@lists.wxwidgets.org
Subject: [wxPython-users] cursor_wait waiting for a result

Sbaush wrote:

Hi all. I've a send/receive function that send a packet and wait for response. i have a function like

self.sender.send(hostto,packet) #self.view.SetCursor(wx.StockCursor(wx.CURSOR_WAIT)) #self.view is a
wx.Frame #Receive response from agent (response,hostfrom)=self.receiver.receive(None)

As you can see i would that while i'm waiting for request i see the cursorWait. Uncommenting my code that doesn't work

How can i do?

In my programs, that function work well. I don't know why your don't,
but I think that it's an "external" wx problem: are your
send(hostto,packet) function blocking? I think that can be the problem.
If yes, can you try to move it to a thread and see what's happen ?

Michele

Sbaush wrote:

Hi all.
I've a send/receive function that send a packet and wait for response.
i have a function like

self.sender.send(hostto,packet)
#self.view.SetCursor(wx.StockCursor(wx.CURSOR_WAIT)) #self.view is a wx.Frame
#Receive response from agent
(response,hostfrom)=self.receiver.receive(None)

As you can see i would that while i'm waiting for request i see the cursorWait.
Uncommenting my code that doesn't work

How can i do?

Depending on your platform the cursor may not actually change until control returns to the main loop and pending events are able to be processed. Since your code blocks on the receive call then the UI framework doesn't get a chance to update the cursor. One way to do this is to insert a call to wx.Yield after the SetCursor, but probably better would be to do your blocking functionality in another thread as others have suggested. See also:

  http://wiki.wxpython.org/index.cgi/LongRunningTasks

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Monday, February 13, 2006, 10:06:12 PM, Sbaush wrote:

Hi all.
I've a send/receive function that send a packet and wait for response.
i have a function like

self.sender.send(hostto,packet)
#self.view.SetCursor(wx.StockCursor(wx.CURSOR_WAIT)) #self.view is a
wx.Frame
#Receive response from agent
(response,hostfrom)=self.receiver.receive(None)

As you can see i would that while i'm waiting for request i see the
cursorWait.
Uncommenting my code that doesn't work

How can i do?

--
Sbaush

Have you tried this:

    wx.BeginBusyCursor()
    # Long running task
    ...
    wx.EndBusyCursor()
    
-- tacao

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

Great, it works perfectly!!

···

2006/2/14, E. A. Tacao e.a.tacao@estadao.com.br:

Monday, February 13, 2006, 10:06:12 PM, Sbaush wrote:

Hi all.
I’ve a send/receive function that send a packet and wait for response.
i have a function like

self.sender.send(hostto,packet)

#self.view.SetCursor(wx.StockCursor(wx.CURSOR_WAIT)) #self.view is a
wx.Frame
#Receive response from agent
(response,hostfrom)=self.receiver.receive(None)

As you can see i would that while i’m waiting for request i see the

cursorWait.
Uncommenting my code that doesn’t work

How can i do?


Sbaush

Have you tried this:

wx.BeginBusyCursor()
# Long running task
...

wx.EndBusyCursor()

– tacao

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


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


Sbaush