2

im new at Python and QT. Here is my Code Snipped.

form_class = uic.loadUiType("mainWindow.ui")[0]  # Load the UI

class MyWindowClass(QtGui.QMainWindow, form_class):
    def __init__(self, parent=None):
        QtGui.QMainWindow.__init__(self, parent)
        self.setupUi(self)
        self.showFullScreen()
        self.loginFPBut.clicked.connect(lambda: self.loginFP)

    def loginFP(self):
        self.labelSensorStatus.setText('Button pressed') 

app = QtGui.QApplication(sys.argv)
myWindow = MyWindowClass(None)
myWindow.show()
app.exec_()

How can i change the Text from Label called "labelSensorStatus"?

  • 2
    I don't see `labelSensorStatus` in your code. Do you have it in `.ui` file ? – furas Jan 28 '17 at 17:43
  • in my .ui file it appears as a normal Qlabel Object. In my Code you can see it in function "loginFP", which is called by pressing a Button called "loginFPBut". – Marcwa19197 Jan 28 '17 at 17:49
  • Removing the "**lambda:**" tag in your connection and using ` self.loginFPBut.clicked.connect(self.loginFP)` the code seems fine and works. – jgorostegui Jan 29 '17 at 02:02
  • Now i get: `Traceback (most recent call last): File "start.py", line 68, in myWindow = MyWindowClass(None) File "start.py", line 34, in __init__ self.loginFPBut.clicked.connect(self.loginFP) TypeError: connect() slot argument should be a callable or a signal, not 'QWidget'` – Marcwa19197 Jan 29 '17 at 11:57

0 Answers0