Posts

Showing posts with the label qpushbutton

Disable enterkey for next button pyqt5 QWizard

Disable enterkey for next button pyqt5 QWizard I am making a Wizard in QWizard QWizard I have QLineEdit and QPushButton QLineEdit QPushButton # Enter token self.enter_token_box = QLineEdit() # Enter token button self.btn = QPushButton('OK') # connect button to function, checks the token.. self.btn.clicked.connect(self._EnterToken) I have put in this line which accepts an enter key press and runs the function the same as clicking the "OK" button. # Enter key press connection self.enter_token_box.returnPressed.connect(self._EnterToken) The problem is that it will trigger BOTH the OK button AND the Next button of the wizard. OK Next MVCE: import sys from PyQt5.QtGui import * from PyQt5.QtCore import * from PyQt5.QtWidgets import * class Wizard(QWizard): def __init__(self, parent=None): super(Wizard, self).__init__(parent) self.addPage(EnterToken(self)) self.addPage(ProcessData(self)) class EnterToken(QWizardPage): def __init__(self, p...