Mar-02-2021, 04:30 PM
(This post was last modified: Mar-02-2021, 04:30 PM by deanhystad.)
This:
And for widgets that you will never reference, there is no need to keep a reference in your class. Will you ever use snLabel, modelLabel or userLabel?
self.cfButton.clicked.connect(print(serialNumber))calls the print function and connects "clicked" to the return value, which is None. You need to connect "clicked" to a function, not a function call. This would work.
def print_serialnumber(): print(self.snTextBox.text()) ... self.cfButton.clicked.connect(print_serialnumber)If you don't want to write a function, you can use a lambda expression, essentially an in-line function.
self.cfButton.clicked.connect(lambda: print(self.snTextBox.text())In the future please provide enough of an example that others can run the code.
And for widgets that you will never reference, there is no need to keep a reference in your class. Will you ever use snLabel, modelLabel or userLabel?
layout = QVBoxLayout(self) layout.addWidget(QLabel("SERIAL NUMBER")) layout.addWidget(self.snTextBox) layout.addWidget(QLabel("MODEL")) layout.addWidget(self.modelTextBox) layout.addWidget(QLabel("USER")) layout.addWidget(self.userTextBox) layout.addWidget(self.activeCheckbox) layout.addWidget(self.enButton) layout.addWidget(self.cfButton) layout.addWidget(self.seButton)