I would like to disable the “Back” button on a QWizard page.
My Class inherits from QWizard and from a generated file. It looks somehow like this:
from PyQt4 import QtGui
JavaScript
x
8
1
class WizardClass(QtGui.QWizard, file.Ui_Wizard):
2
3
def __init__(self, model):
4
# Call super constructors
5
QtGui.QWizard.__init__(self)
6
self.setupUi(self)
7
self.model = model
8
Here http://doc.qt.digia.com/3.3/qwizard.html#backButton I found the method setBackEnabled()
.
With self.setBackEnabled(page1, False)
I am not able to call this method. It says:
JavaScript
1
2
1
"AttributeError: 'WizardClass' object has no attribute 'setBackEnabled'"
2
Am I doing something wrong?
Or is this method not available in Python?
Advertisement
Answer
An example that seems to work:
JavaScript
1
25
25
1
from PyQt4 import QtGui
2
3
class Wiz(QtGui.QWizard):
4
5
def __init__(self):
6
QtGui.QWizard.__init__(self)
7
self.noback = []
8
self.currentIdChanged.connect(self.disable_back)
9
10
def disable_back(self, ind):
11
if ind in self.noback:
12
self.button(QtGui.QWizard.BackButton).setEnabled(False)
13
14
wiz = Wiz()
15
wiz.noback = [2]
16
wiz1 = QtGui.QWizardPage(wiz)
17
wiz2 = QtGui.QWizardPage(wiz)
18
wiz3 = QtGui.QWizardPage(wiz)
19
20
wiz.addPage(wiz1)
21
wiz.addPage(wiz2)
22
wiz.addPage(wiz3)
23
24
wiz.show()
25