wxPython 更改鼠标光标以通知长时间运行的操作
我正在构建一个 Python 程序来搜索远程网站上的内容。 有时操作需要花费很多秒,我相信用户不会注意到状态栏消息“搜索操作正在进行”。 因此,我想改变鼠标光标以突出显示程序仍在等待结果。
这是我正在使用的方法:
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)
我尝试了两种不同的方法,都在最后一行之前:
- wx.BeginBusyCursor()
- self.m_frame.SetCursor(wx.StockCursor(wx.CURSOR_WAIT))
它们都不起作用。
我在 GNU/Linux 下使用 KDE。这在 Gnome 下也不起作用
有什么提示吗?谢谢
I am building a Python program that searches things on a remote website.
Sometimes the 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 a result.
This is the method I am using:
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, both before the last line:
- wx.BeginBusyCursor()
- self.m_frame.SetCursor(wx.StockCursor(wx.CURSOR_WAIT))
None of them are working.
I am using KDE under GNU/Linux. This does not work under Gnome, too
Any hints? Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我向 wxPython 的创建者 Robin Dunn 询问了这个问题,看起来这应该可行,但事实并非如此。但是,如果您调用面板的 SetCursor(),它确实可以工作,或者我被告知。这是您可以尝试的示例:
I asked Robin Dunn, the maker of wxPython about this, and it looks like this should work, but doesn't. However, if you call the panel's SetCursor(), it DOES work or so I'm told. Here's an example you can try: