I'm beginning with PyQt, and want to start with a basic calculator as training example. I've designed the UI with Qt Designer, and convert with PyUIC. Now I want that when I push the button "1" then the "screen" shows "1".
class Ui_Dialog(object):
def setupUi(self, Dialog):
# ...
self.Qpush1.clicked.connect(self.btClicked)
def btClicked(self):
self.CalcScreen.setText("1")
It works well. But do I need a function for each button? I've seen something like (e.g. shown here):
def btClicked(self):
sender = self.sender()
self.CalcScreen.setText(sender.text())
But it doesn't work; when I click the button the program crashes without error message to help me: "Process finished with exit code -1073740791".