class Ui_Form(QtWidgets.QWidget):
def __init__(self):
super(self.__class__, self).__init__()
self.setupUi(self)
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(410, 325)
font = QtGui.QFont()
font.setBold(True)
font.setUnderline(False)
font.setWeight(75)
Form.setFont(font)
self.gridLayout = QtWidgets.QGridLayout(Form)
self.gridLayout.setObjectName("gridLayout")
self.verticalLayout = QtWidgets.QVBoxLayout()
self.verticalLayout.setObjectName("verticalLayout")
self.label = QtWidgets.QLabel(Form)
font = QtGui.QFont()
font.setPointSize(12)
self.label.setFont(font)
self.label.setObjectName("label")
self.verticalLayout.addWidget(self.label)
self.label_4 = QtWidgets.QLabel(Form)
self.label_4.setObjectName("label_4")
self.verticalLayout.addWidget(self.label_4)
self.lineEdit_2 = QtWidgets.QLineEdit(Form)
self.lineEdit_2.setObjectName("lineEdit_2")
self.verticalLayout.addWidget(self.lineEdit_2)
self.label_5 = QtWidgets.QLabel(Form)
self.label_5.setObjectName("label_5")
self.verticalLayout.addWidget(self.label_5)
self.lineEdit = QtWidgets.QLineEdit(Form)
self.lineEdit.setObjectName("lineEdit")
self.verticalLayout.addWidget(self.lineEdit)
spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Minimum)
self.verticalLayout.addItem(spacerItem)
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
self.pushButton_2 = QtWidgets.QPushButton(Form)
self.pushButton_2.setObjectName("pushButton_2")
self.horizontalLayout.addWidget(self.pushButton_2)
self.pushButton = QtWidgets.QPushButton(Form)
self.pushButton.setObjectName("pushButton")
self.horizontalLayout.addWidget(self.pushButton)
self.verticalLayout.addLayout(self.horizontalLayout)
self.progressBar = QtWidgets.QProgressBar(Form)
self.progressBar.setProperty("value", 0)
self.progressBar.setObjectName("progressBar")
self.verticalLayout.addWidget(self.progressBar)
self.gridLayout.addLayout(self.verticalLayout, 0, 0, 1, 1)
self.pushButton_2.clicked.connect(self.Entrar)
self.pushButton.clicked.connect(self.Cadastrar)
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("Form", "Gerenciador de Ordem de Serviço"))
self.label.setText(_translate("Form", "Faça login ou cadastre-se"))
self.label_4.setText(_translate("Form", "Login:"))
self.label_5.setText(_translate("Form", "Senha:"))
self.pushButton_2.setText(_translate("Form", "Entrar"))
self.pushButton.setText(_translate("Form", "Cadastrar"))
def Entrar(self): #aqui faz a busca dos dados de cadastro, se corretos e cadastrados vai para programa principal
log = self.lineEdit.text()
passw = self.lineEdit_2.text()
logqry = 'SELECT NomeUsu FROM registro WHERE NomeUsu =' + "\""+ log +"\""
passqry = 'SELECT SenhaProg FROM registro WHERE SenhaProg =' + "\"" + passw + "\""
print(self.lineEdit.text())
print(log)
print(passw)
print(logqry)
print(passqry)
Hi, I have this part of my code, is that a gui, and a did a method that it's supposed to print the value of the LineEdit and LineEdit_2 value, but when I run the event the , that don't show nothing, like the lineEdit was empty.
Can anyone help?? Sorry about any gramatical mistake.
log
and passw
are not ordinary Python strings, they're QString
s, so to print them you have to convert them to strings first.
log = str(self.lineEdit.text())
passw = str(self.lineEdit_2.text())
Or, If you want them to be QString
s, print them as follows
print("%s\n%s" % log,passw)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.