0

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".

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
Medestrac
  • 27
  • 4
  • It doesn't work because you're editing a pyuic generated file, which you're not supposed to (as its header clearly suggests). Follow the official guidelines about [using Designer](https://www.riverbankcomputing.com/static/Docs/PyQt5/designer.html) instead, and use a QWidget subclass. – musicamante May 30 '23 at 10:51

0 Answers0