Changing a labels visibility using PyQT
pyqt, python
Solution
From where are you pasting these two code snippets? In your MainWindow init? Whatever it is, you probably want to hide the button right after it is created:
self.label_3 = QtGui.QLabel(Form)
self.label_3.hide()
And connect the button's clicked signal to the label's show() method:
self.submitButton.clicked.connect(self.label_3.show)
Problem
I have created a form in QtDesigner and converted it into a python document using PyQt. In my QtDesigner document I have added the label that reads "You have successfully sent in the form". What I want to do is hide this label until the submit button has been clicked. I'm struggling because of the complex format of the PyQt document. This is the code for submit and label (submitButton, label_3): ``` self.submitButton = QtGui.QPushButton(Form) self.submitButton.setObjectName(_fromUtf8("submitButton")) self.verticalLayout.addWidget(self.submitButton) class Ui_Form(QtGui.QWidget): def setupUi(self, Form): self.label_3 = QtGui.QLabel(Form) self.label_3.setStyleSheet(_fromUtf8("QLabel\n" "{\n" " font: bold 14pt \"helvetica\";\n" " color: darkgreen;\n" "}")) self.label_3.setScaledContents(False) self.label_3.setWordWrap(False) self.label_3.setObjectName(_fromUtf8("label_3")) self.verticalLayout.addWidget(self.label_3) self.horizontalLayout.addLayout(self.verticalLayout) self.retranslateUi(Form) QtCore.QMetaObject.connectSlotsByName(Form) ``` Here's roughly what i'm doing (codes is wrong, I know, but hopefully it helps you understand my problem. ``` label_3.hide() == True if submitButton.clicked label_3.show() == True ```