wx python 3.0.2 classic - disable the Cancel button of wx.ProgressDialog

女生的网名这么多〃 提交于 2019-12-12 03:57:10

问题


More problems with my lovely custom Progress class moving on to wx python 3 (see wx python 3.0.2 classic SetFocus blows for part I)

This:

def setCancel(self, enabled=True):
    cancel = self.dialog.FindWindowById(wx.ID_CANCEL)
    cancel.Enable(enabled)

used to work just fine in 2.8.12.1 unicode, while crashes in 3.02 with:

Traceback (most recent call last):
  File "bash\balt.py", line 419, in <lambda>
    if onButClick: self.Bind(wx.EVT_BUTTON, lambda __event: onButClick())
  File "bash\balt.py", line 1565, in _conversation_wrapper
    return func(*args, **kwargs)
  File "bash\basher\patcher_dialog.py", line 204, in PatchExecute
    progress.setCancel(False)
  File "bash\balt.py", line 1317, in setCancel
    cancel.Enable(enabled)
AttributeError: 'NoneType' object has no attribute 'Enable'

self.dialog is a wx.ProgressDialog. From what I read here in How to override the “Cancel” button event of a ProgressDialog?

I suspect the native widget won't allow you to access the Cancel button at all, but I'm not sure.

and from the answer by @RobinDunn to my previous question:

On Windows the ProgressDialog [...] has no native window handle, and most non-ProgressDialog-specific APIs like SetFocus will not work.

(emphasis mine)

Does this mean that I cant't disable the cancel button of a progress dialog anymore ?

来源:https://stackoverflow.com/questions/42890766/wx-python-3-0-2-classic-disable-the-cancel-button-of-wx-progressdialog

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!