问题
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