WxPython will change the mouse cursor to a notification of continuous operation

I am creating a Python program that searches for things on a remote website. Sometimes an operation takes many seconds, and I believe that the user will not notice the status bar message "Search operation in progress." Therefore, I would like to change the mouse cursor to highlight that the program is still waiting for the result.

This is the method I use:

def OnButtonSearchClick( self, event ): """ If there is text in the search text, launch a SearchOperation. """ searched_value = self.m_search_text.GetValue() if not searched_value: return # clean eventual previous results self.EnableButtons(False) self.CleanSearchResults() operations.SearchOperation(self.m_frame, searched_value) 

I tried two different approaches, as to the last line:

  • wx.BeginBusyCursor ()
  • self.m_frame.SetCursor (wx.StockCursor (wx.CURSOR_WAIT))

None of them work.

I am using KDE under GNU / Linux. This also does not work under Gnome.

Any clues? Thanks you

+6
source share
1 answer

I asked Robin Dunn, the manufacturer of wxPython, about this, and it looks like this should work, but it is not. However, if you call the SetCursor () panel, it works, or so they tell me. Here is an example you can try:

 import wx ######################################################################## class MyForm(wx.Frame): #---------------------------------------------------------------------- def __init__(self): wx.Frame.__init__(self, None, wx.ID_ANY, "Tutorial") # Add a self.panel so it looks the correct on all platforms self.panel = wx.Panel(self, wx.ID_ANY) btn = wx.Button(self.panel, label="Change Cursor") btn.Bind(wx.EVT_BUTTON, self.changeCursor) sizer = wx.BoxSizer(wx.HORIZONTAL) sizer.Add(btn) self.panel.SetSizer(sizer) #---------------------------------------------------------------------- def changeCursor(self, event): """""" myCursor= wx.StockCursor(wx.CURSOR_WAIT) self.panel.SetCursor(myCursor) #---------------------------------------------------------------------- # Run the program if __name__ == "__main__": app = wx.PySimpleApp() frame = MyForm().Show() app.MainLoop() 
+6
source

Source: https://habr.com/ru/post/900209/


All Articles