Python Beginners error - python

I have this really "big" code
class ClassePrincipal(object):
def __init__(self):
super(self.__class__, self).__init__()
self.setupUi(self)
def setupUi(self, MainWindow):
MainWindow.setObjectName
MainWindow.setObjectName("MainWindow")
MainWindow.resize(464, 501)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.gridLayout_2 = QtWidgets.QGridLayout(self.centralwidget)
self.gridLayout_2.setObjectName("gridLayout_2")
self.scrollArea = QtWidgets.QScrollArea(self.centralwidget)
self.scrollArea.setWidgetResizable(True)
self.scrollArea.setObjectName("scrollArea")
self.scrollAreaWidgetContents = QtWidgets.QWidget()
self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 427, 719))
self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents")
self.gridLayout = QtWidgets.QGridLayout(self.scrollAreaWidgetContents)
self.gridLayout.setObjectName("gridLayout")
self.verticalLayout = QtWidgets.QVBoxLayout()
self.verticalLayout.setObjectName("verticalLayout")
self.label = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label.setObjectName("label")
self.verticalLayout.addWidget(self.label)
self.lineEdit = QtWidgets.QLineEdit(self.scrollAreaWidgetContents)
self.lineEdit.setObjectName("lineEdit")
self.verticalLayout.addWidget(self.lineEdit)
self.label_2 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_2.setObjectName("label_2")
self.verticalLayout.addWidget(self.label_2)
self.lineEdit_2 = QtWidgets.QLineEdit(self.scrollAreaWidgetContents)
self.lineEdit_2.setObjectName("lineEdit_2")
self.verticalLayout.addWidget(self.lineEdit_2)
self.label_3 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_3.setObjectName("label_3")
self.verticalLayout.addWidget(self.label_3)
self.lineEdit_3 = QtWidgets.QLineEdit(self.scrollAreaWidgetContents)
self.lineEdit_3.setObjectName("lineEdit_3")
self.verticalLayout.addWidget(self.lineEdit_3)
self.label_4 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_4.setObjectName("label_4")
self.verticalLayout.addWidget(self.label_4)
self.lineEdit_4 = QtWidgets.QLineEdit(self.scrollAreaWidgetContents)
self.lineEdit_4.setObjectName("lineEdit_4")
self.verticalLayout.addWidget(self.lineEdit_4)
self.label_5 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_5.setObjectName("label_5")
self.verticalLayout.addWidget(self.label_5)
self.lineEdit_5 = QtWidgets.QLineEdit(self.scrollAreaWidgetContents)
self.lineEdit_5.setObjectName("lineEdit_5")
self.verticalLayout.addWidget(self.lineEdit_5)
self.label_6 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_6.setObjectName("label_6")
self.verticalLayout.addWidget(self.label_6)
self.lineEdit_6 = QtWidgets.QLineEdit(self.scrollAreaWidgetContents)
self.lineEdit_6.setObjectName("lineEdit_6")
self.verticalLayout.addWidget(self.lineEdit_6)
self.label_7 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_7.setObjectName("label_7")
self.verticalLayout.addWidget(self.label_7)
self.dateEdit = QtWidgets.QDateEdit(self.scrollAreaWidgetContents)
self.dateEdit.setObjectName("dateEdit")
self.verticalLayout.addWidget(self.dateEdit)
self.label_8 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_8.setObjectName("label_8")
self.verticalLayout.addWidget(self.label_8)
self.lineEdit_8 = QtWidgets.QLineEdit(self.scrollAreaWidgetContents)
self.lineEdit_8.setObjectName("lineEdit_8")
self.verticalLayout.addWidget(self.lineEdit_8)
self.label_9 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_9.setObjectName("label_9")
self.verticalLayout.addWidget(self.label_9)
self.horizontalLayout_3 = QtWidgets.QHBoxLayout()
self.horizontalLayout_3.setObjectName("horizontalLayout_3")
self.radioButton_4 = QtWidgets.QRadioButton(self.scrollAreaWidgetContents)
self.radioButton_4.setObjectName("radioButton_4")
self.horizontalLayout_3.addWidget(self.radioButton_4)
self.radioButton_3 = QtWidgets.QRadioButton(self.scrollAreaWidgetContents)
self.radioButton_3.setObjectName("radioButton_3")
self.horizontalLayout_3.addWidget(self.radioButton_3)
self.radioButton_2 = QtWidgets.QRadioButton(self.scrollAreaWidgetContents)
self.radioButton_2.setObjectName("radioButton_2")
self.horizontalLayout_3.addWidget(self.radioButton_2)
self.radioButton = QtWidgets.QRadioButton(self.scrollAreaWidgetContents)
self.radioButton.setObjectName("radioButton")
self.horizontalLayout_3.addWidget(self.radioButton)
self.verticalLayout.addLayout(self.horizontalLayout_3)
self.label_10 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_10.setObjectName("label_10")
self.verticalLayout.addWidget(self.label_10)
self.lineEdit_7 = QtWidgets.QLineEdit(self.scrollAreaWidgetContents)
self.lineEdit_7.setObjectName("lineEdit_7")
self.verticalLayout.addWidget(self.lineEdit_7)
self.label_11 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_11.setObjectName("label_11")
self.verticalLayout.addWidget(self.label_11)
self.textEdit = QtWidgets.QTextEdit(self.scrollAreaWidgetContents)
self.textEdit.setObjectName("textEdit")
self.verticalLayout.addWidget(self.textEdit)
self.label_12 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_12.setObjectName("label_12")
self.verticalLayout.addWidget(self.label_12)
self.horizontalLayout_4 = QtWidgets.QHBoxLayout()
self.horizontalLayout_4.setObjectName("horizontalLayout_4")
self.graphicsView = QtWidgets.QGraphicsView(self.scrollAreaWidgetContents)
self.graphicsView.setObjectName("graphicsView")
self.horizontalLayout_4.addWidget(self.graphicsView)
self.pushButton = QtWidgets.QPushButton(self.scrollAreaWidgetContents)
self.pushButton.setObjectName("pushButton")
self.horizontalLayout_4.addWidget(self.pushButton)
self.verticalLayout.addLayout(self.horizontalLayout_4)
self.horizontalLayout_5 = QtWidgets.QHBoxLayout()
self.horizontalLayout_5.setObjectName("horizontalLayout_5")
self.pushButton_2 = QtWidgets.QPushButton(self.scrollAreaWidgetContents)
self.pushButton_2.setObjectName("pushButton_2")
self.horizontalLayout_5.addWidget(self.pushButton_2)
self.pushButton_3 = QtWidgets.QPushButton(self.scrollAreaWidgetContents)
self.pushButton_3.setObjectName("pushButton_3")
self.horizontalLayout_5.addWidget(self.pushButton_3)
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_5.addItem(spacerItem)
self.pushButton_4 = QtWidgets.QPushButton(self.scrollAreaWidgetContents)
self.pushButton_4.setObjectName("pushButton_4")
self.horizontalLayout_5.addWidget(self.pushButton_4)
self.verticalLayout.addLayout(self.horizontalLayout_5)
self.horizontalLayout_6 = QtWidgets.QHBoxLayout()
self.horizontalLayout_6.setObjectName("horizontalLayout_6")
self.pushButton_5 = QtWidgets.QPushButton(self.scrollAreaWidgetContents)
self.pushButton_5.setObjectName("pushButton_5")
self.horizontalLayout_6.addWidget(self.pushButton_5)
self.comboBox = QtWidgets.QComboBox(self.scrollAreaWidgetContents)
self.comboBox.setObjectName("comboBox")
self.comboBox.addItem("")
self.comboBox.addItem("")
self.comboBox.addItem("")
self.horizontalLayout_6.addWidget(self.comboBox)
self.lineEdit_9 = QtWidgets.QLineEdit(self.scrollAreaWidgetContents)
self.lineEdit_9.setObjectName("lineEdit_9")
self.horizontalLayout_6.addWidget(self.lineEdit_9)
self.verticalLayout.addLayout(self.horizontalLayout_6)
self.gridLayout.addLayout(self.verticalLayout, 1, 0, 1, 1)
self.scrollArea.setWidget(self.scrollAreaWidgetContents)
self.gridLayout_2.addWidget(self.scrollArea, 0, 0, 1, 1)
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 464, 21))
self.menubar.setObjectName("menubar")
self.menuArquivos = QtWidgets.QMenu(self.menubar)
self.menuArquivos.setObjectName("menuArquivos")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.actionSalvar = QtWidgets.QAction(MainWindow)
self.actionSalvar.setObjectName("actionSalvar")
self.actionClose = QtWidgets.QAction(MainWindow)
self.actionClose.setObjectName("actionClose")
self.actionClose_2 = QtWidgets.QAction(MainWindow)
self.actionClose_2.setObjectName("actionClose_2")
self.menuArquivos.addAction(self.actionSalvar)
self.menuArquivos.addAction(self.actionClose)
self.menuArquivos.addAction(self.actionClose_2)
self.menubar.addAction(self.menuArquivos.menuAction())
self.retranslateUi(MainWindow)
self.actionClose_2.triggered.connect(MainWindow.close)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
self.label.setText(_translate("MainWindow", "Nome do Solicitante"))
self.label_2.setText(_translate("MainWindow", "CNPJ"))
self.label_3.setText(_translate("MainWindow", "Email do Solicitante"))
self.label_4.setText(_translate("MainWindow", "Razão Social"))
self.label_5.setText(_translate("MainWindow", "Endereço do Solicitante"))
self.label_6.setText(_translate("MainWindow", "Endereço do Serviço"))
self.label_7.setText(_translate("MainWindow", "Data"))
self.label_8.setText(_translate("MainWindow", "Valor so Serviço"))
self.label_9.setText(_translate("MainWindow", "Forma de Pagamento"))
self.radioButton_4.setText(_translate("MainWindow", "RadioButton"))
self.radioButton_3.setText(_translate("MainWindow", "RadioButton"))
self.radioButton_2.setText(_translate("MainWindow", "RadioButton"))
self.radioButton.setText(_translate("MainWindow", "RadioButton"))
self.label_10.setText(_translate("MainWindow", "Equipamentos Usados"))
self.label_11.setText(_translate("MainWindow", "Descrição do Serviço"))
self.label_12.setText(_translate("MainWindow", "Imagem"))
self.pushButton.setText(_translate("MainWindow", "Procurar..."))
self.pushButton_2.setText(_translate("MainWindow", "Enviar via Email"))
self.pushButton_3.setText(_translate("MainWindow", "Salvar"))
self.pushButton_4.setText(_translate("MainWindow", "Cancelar"))
self.pushButton_5.setText(_translate("MainWindow", "Busca Banco de Dados"))
self.comboBox.setItemText(0, _translate("MainWindow", "CNPJ"))
self.comboBox.setItemText(1, _translate("MainWindow", "Nome do Solicitante"))
self.comboBox.setItemText(2, _translate("MainWindow", "Data"))
self.menuArquivos.setTitle(_translate("MainWindow", "Arquivos"))
self.actionSalvar.setText(_translate("MainWindow", "Salvar"))
self.actionClose.setText(_translate("MainWindow", "Apagar"))
self.actionClose_2.setText(_translate("MainWindow", "Close"))
def main():
app = QApplication(sys.argv)
Mw = ClassePrincipal()
Mw.show()
app.exec_()
if __name__ == '__main__':
main()
But I'm having this error msg
Traceback (most recent call last):
File "C:/Users/Alexandre/Documents/Python/FinalmenteUltimo.py", line 221, in <module>
main()
File "C:/Users/Alexandre/Documents/Python/FinalmenteUltimo.py", line 215, in main
Mw = ClassePrincipal()
File "C:/Users/Alexandre/Documents/Python/FinalmenteUltimo.py", line 14, in __init__
self.setupUi(self)
File "C:/Users/Alexandre/Documents/Python/FinalmenteUltimo.py", line 17, in setupUi
MainWindow.setObjectName
AttributeError: 'ClassePrincipal' object has no attribute 'setObjectName'
But, I've been reading about this module, and there is this attribute.
Can someone help me, I'm realy noob about python, This is my firt program, and I have no idea what is happening.
Since now, thank you.
Ps: I used QT Designer.

As the error message implies, there is an error in line 17:
I guess you mistakenly wrote 'MainWindow.setObjectName' two times, but the first time without parameter. So Python is "thinking" you refer to an attribute with this name instead of a method and the underlying class does not have such an attribute (as described in the error).

I believe this file is generated by pyuic5. You should avoid editing computer generated file by hand. If you have .ui file you can try to generate py file using pyuic5 link below might help you out
http://pyqt.sourceforge.net/Docs/PyQt5/designer.html
Can you make your class extend QMainWindow and change the parts with MainWindow to self like below in setupUi. If this doesnt work create your file using Main Window option use -x flag on pyuic5 it will give you executable python code which is better option. also the link below should be helpful
self.setObjectName("MainWindow")
self.resize(464, 501)
http://www.rkblog.rk.edu.pl/w/p/simple-text-editor-pyqt4/

I did it, to fix that i just did
instead:
class ClassePrincipal(object):
I used
class ClassePrincipal(QMainWindow):
Thank you anyway.

Related

Stackwidget in Pyqt5 python

I'm creating a screen with StackWidget consist of 3 pages.
The problem is that only one page of the stackwidget pages showing all widgets inside it but the other pages cutting three element in the corners, see the photos
the error page:
correct page and i want the other pages show all widgets in the four corners :
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(1200, 679)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.pushButton = QtWidgets.QPushButton(self.centralwidget)
self.pushButton.setGeometry(QtCore.QRect(30, 100, 93, 28))
self.pushButton.setObjectName("pushButton")
self.pushButton_2 = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_2.setGeometry(QtCore.QRect(30, 220, 93, 28))
self.pushButton_2.setObjectName("pushButton_2")
self.pushButton_3 = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_3.setGeometry(QtCore.QRect(30, 330, 93, 28))
self.pushButton_3.setObjectName("pushButton_3")
self.stackedWidget = QtWidgets.QStackedWidget(self.centralwidget)
self.stackedWidget.setGeometry(QtCore.QRect(170, 0, 1011, 631))
self.stackedWidget.setObjectName("stackedWidget")
self.page_3 = QtWidgets.QWidget()
self.page_3.setObjectName("page_3")
self.pushButton_4 = QtWidgets.QPushButton(self.page_3)
self.pushButton_4.setGeometry(QtCore.QRect(10, 10, 93, 28))
self.pushButton_4.setObjectName("pushButton_4")
self.pushButton_5 = QtWidgets.QPushButton(self.page_3)
self.pushButton_5.setGeometry(QtCore.QRect(880, 20, 93, 28))
self.pushButton_5.setObjectName("pushButton_5")
self.pushButton_6 = QtWidgets.QPushButton(self.page_3)
self.pushButton_6.setGeometry(QtCore.QRect(10, 580, 93, 28))
self.pushButton_6.setObjectName("pushButton_6")
self.pushButton_7 = QtWidgets.QPushButton(self.page_3)
self.pushButton_7.setGeometry(QtCore.QRect(890, 590, 93, 28))
self.pushButton_7.setObjectName("pushButton_7")
self.stackedWidget.addWidget(self.page_3)
self.page_4 = QtWidgets.QWidget()
self.page_4.setObjectName("page_4")
self.lineEdit = QtWidgets.QLineEdit(self.page_4)
self.lineEdit.setGeometry(QtCore.QRect(10, 30, 113, 22))
self.lineEdit.setObjectName("lineEdit")
self.lineEdit_2 = QtWidgets.QLineEdit(self.page_4)
self.lineEdit_2.setGeometry(QtCore.QRect(870, 580, 113, 22))
self.lineEdit_2.setObjectName("lineEdit_2")
self.lineEdit_3 = QtWidgets.QLineEdit(self.page_4)
self.lineEdit_3.setGeometry(QtCore.QRect(30, 570, 113, 22))
self.lineEdit_3.setObjectName("lineEdit_3")
self.lineEdit_4 = QtWidgets.QLineEdit(self.page_4)
self.lineEdit_4.setGeometry(QtCore.QRect(860, 30, 113, 22))
self.lineEdit_4.setObjectName("lineEdit_4")
self.stackedWidget.addWidget(self.page_4)
self.page_5 = QtWidgets.QWidget()
self.page_5.setObjectName("page_5")
self.calendarWidget = QtWidgets.QCalendarWidget(self.page_5)
self.calendarWidget.setGeometry(QtCore.QRect(10, 10, 392, 236))
self.calendarWidget.setObjectName("calendarWidget")
self.calendarWidget_2 = QtWidgets.QCalendarWidget(self.page_5)
self.calendarWidget_2.setGeometry(QtCore.QRect(600, 20, 392, 236))
self.calendarWidget_2.setObjectName("calendarWidget_2")
self.calendarWidget_3 = QtWidgets.QCalendarWidget(self.page_5)
self.calendarWidget_3.setGeometry(QtCore.QRect(610, 380, 392, 236))
self.calendarWidget_3.setObjectName("calendarWidget_3")
self.calendarWidget_4 = QtWidgets.QCalendarWidget(self.page_5)
self.calendarWidget_4.setGeometry(QtCore.QRect(10, 380, 392, 236))
self.calendarWidget_4.setObjectName("calendarWidget_4")
self.stackedWidget.addWidget(self.page_5)
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 1200, 26))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
self.stackedWidget.setCurrentIndex(2)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
self.pushButton.setText(_translate("MainWindow", "1"))
self.pushButton_2.setText(_translate("MainWindow", "2"))
self.pushButton_3.setText(_translate("MainWindow", "3"))
self.pushButton_4.setText(_translate("MainWindow", "PushButton"))
self.pushButton_5.setText(_translate("MainWindow", "PushButton"))
self.pushButton_6.setText(_translate("MainWindow", "PushButton"))
self.pushButton_7.setText(_translate("MainWindow", "PushButton"))
Blockquote
import sys
from PyQt5.QtWidgets import QMainWindow, QApplication, QAction ,QFileDialog
from stackwidgettest import *
class MyForm(QMainWindow):
def __init__(self):
super().__init__()
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.ui.pushButton.clicked.connect(self.moveforward)
self.ui.pushButton_2.clicked.connect(self.moveback)
self.ui.pushButton_3.clicked.connect(self.movebacks)
def moveforward(self):
self.ui.page_3.show()
self.ui.page_4.hide()
self.ui.page_5.hide()
def moveback(self):
self.ui.page_3.hide()
self.ui.page_4.show()
self.ui.page_5.hide()
def movebacks(self):
self.ui.page_3.hide()
self.ui.page_4.hide()
self.ui.page_5.show()
if __name__=="__main__":
app = QApplication(sys.argv)
w = MyForm()
w.show()
sys.exit(app.exec_())
The problem solved by setCurrentIndex() method for the stackwidget

issue with QScrollArea

I am trying to add some check boxes in scroll area.but for me it is not working properly.i am new in python could anyone help?
import PyQt5
from PyQt5 import QtCore, QtGui, QtWidgets
from configparser import ConfigParser
import paramiko
import threading
import os
if hasattr(QtCore.Qt, 'AA_EnableHighDpiScaling'):
PyQt5.QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling, True)
if hasattr(QtCore.Qt, 'AA_UseHighDpiPixmaps'):
PyQt5.QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps, True)
class Ui_MainWindow(object):
def __init__(self, parent=None):
self.configur = ConfigParser()
self.configur.read('ServerConfigurationDetails.ini')
self.serverName=self.configur.sections()
print(self.serverName)
self.getComponents = self.configur.options("Component")
self.sLen = len(self.serverName)
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.setEnabled(True)
MainWindow.resize(951, 634)
font = QtGui.QFont()
font.setPointSize(10)
MainWindow.setFont(font)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.label_2 = QtWidgets.QLabel(self.centralwidget)
self.label_2.setGeometry(QtCore.QRect(150, 220, 91, 31))
font = QtGui.QFont()
font.setPointSize(14)
self.label_2.setFont(font)
self.label_2.setObjectName("label_2")
self.comboBox_2 = QtWidgets.QComboBox(self.centralwidget)
self.comboBox_2.setGeometry(QtCore.QRect(250, 220, 231, 31))
self.comboBox_2.setObjectName("comboBox_2")
self.comboBox_2.addItem("")
self.comboBox_2.addItem("")
self.pushButton = QtWidgets.QPushButton(self.centralwidget)
self.pushButton.setGeometry(QtCore.QRect(700, 40, 101, 31))
self.pushButton.setObjectName("pushButton")
self.groupBox = QtWidgets.QGroupBox(self.centralwidget)
self.groupBox.setGeometry(QtCore.QRect(140, 260, 681, 81))
self.groupBox.setObjectName("groupBox")
self.radioButton = QtWidgets.QRadioButton(self.groupBox)
self.radioButton.setGeometry(QtCore.QRect(10, 30, 201, 20))
self.radioButton.setObjectName("radioButton")
self.radioButton_2 = QtWidgets.QRadioButton(self.groupBox)
self.radioButton_2.setGeometry(QtCore.QRect(220, 30, 201, 20))
self.radioButton_2.setObjectName("radioButton_2")
self.checkBox = QtWidgets.QCheckBox(self.groupBox)
self.checkBox.setEnabled(False)
self.checkBox.setGeometry(QtCore.QRect(10, 50, 231, 31))
self.checkBox.setChecked(True)
self.checkBox.setObjectName("checkBox")
self.radioButton_3 = QtWidgets.QRadioButton(self.groupBox)
self.radioButton_3.setGeometry(QtCore.QRect(420, 30, 171, 20))
self.radioButton_3.setObjectName("radioButton_3")
self.lineEdit = QtWidgets.QLineEdit(self.centralwidget)
self.lineEdit.setGeometry(QtCore.QRect(280, 40, 411, 31))
self.lineEdit.setObjectName("lineEdit")
self.label_3 = QtWidgets.QLabel(self.centralwidget)
self.label_3.setGeometry(QtCore.QRect(130, 40, 131, 31))
self.label_3.setObjectName("label_3")
self.label_5 = QtWidgets.QLabel(self.centralwidget)
self.label_5.setGeometry(QtCore.QRect(140, 125, 661, 21))
self.label_5.setText("")
self.label_5.setObjectName("label_5")
self.scrollArea = QtWidgets.QScrollArea(self.centralwidget)
self.scrollArea.setGeometry(QtCore.QRect(130, 110, 681, 101))
self.scrollArea.setAccessibleDescription("")
self.scrollArea.setWidgetResizable(False)
self.scrollArea.setObjectName("scrollArea")
self.scrollAreaWidgetContents = QtWidgets.QWidget()
self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 679, 99))
self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents")
c=10
n=0
x = 10
y = 10
print(self.sLen)
for i in range(self.sLen):
if(n==4):
n=0
x=10
y=y+20
self.checkbox1 = QtWidgets.QCheckBox(self.scrollAreaWidgetContents)
self.checkbox1.setGeometry(QtCore.QRect(x+1, y+1, 161, 20))
self.checkbox1.setText(self.serverName[i])
self.checkbox1.setObjectName(self.serverName[i])
print(x)
print(n)
n=n+1
if(n==4):
x=10
y = y+20
else:
x= x+180
## self.checkBox_2 = QtWidgets.QCheckBox(self.scrollAreaWidgetContents)
## self.checkBox_2.setGeometry(QtCore.QRect(10, 10, 161, 20))
## self.checkBox_2.setObjectName("checkBox_2")
## self.checkBox_3 = QtWidgets.QCheckBox(self.scrollAreaWidgetContents)
## self.checkBox_3.setGeometry(QtCore.QRect(180, 10, 131, 20))
## self.checkBox_3.setObjectName("checkBox_3")
## self.checkBox_4 = QtWidgets.QCheckBox(self.scrollAreaWidgetContents)
## self.checkBox_4.setGeometry(QtCore.QRect(350, 10, 151, 20))
## self.checkBox_4.setObjectName("checkBox_4")
## self.checkBox_5 = QtWidgets.QCheckBox(self.scrollAreaWidgetContents)
## self.checkBox_5.setGeometry(QtCore.QRect(530, 10, 141, 20))
## self.checkBox_5.setObjectName("checkBox_5")
## self.checkBox_6 = QtWidgets.QCheckBox(self.scrollAreaWidgetContents)
## self.checkBox_6.setGeometry(QtCore.QRect(10, 30, 161, 20))
## self.checkBox_6.setObjectName("checkBox_6")
self.scrollArea.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
self.scrollArea.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.scrollArea.setWidget(self.scrollAreaWidgetContents)
self.scrollArea_2 = QtWidgets.QScrollArea(self.centralwidget)
self.scrollArea_2.setGeometry(QtCore.QRect(140, 380, 681, 191))
self.scrollArea_2.setWidgetResizable(True)
self.scrollArea_2.setObjectName("scrollArea_2")
self.scrollAreaWidgetContents_2 = QtWidgets.QWidget()
self.scrollAreaWidgetContents_2.setGeometry(QtCore.QRect(0, 0, 679, 189))
self.scrollAreaWidgetContents_2.setObjectName("scrollAreaWidgetContents_2")
self.scrollArea_2.setWidget(self.scrollAreaWidgetContents_2)
self.line = QtWidgets.QFrame(self.centralwidget)
self.line.setGeometry(QtCore.QRect(70, 340, 811, 20))
self.line.setFrameShape(QtWidgets.QFrame.HLine)
self.line.setFrameShadow(QtWidgets.QFrame.Sunken)
self.line.setObjectName("line")
MainWindow.setCentralWidget(self.centralwidget)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 951, 26))
self.menubar.setObjectName("menubar")
self.menuhelp = QtWidgets.QMenu(self.menubar)
self.menuhelp.setObjectName("menuhelp")
MainWindow.setMenuBar(self.menubar)
self.actionAbout = QtWidgets.QAction(MainWindow)
self.actionAbout.setObjectName("actionAbout")
self.menuhelp.addAction(self.actionAbout)
self.menubar.addAction(self.menuhelp.menuAction())
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
self.label_2.setText(_translate("MainWindow", "<html><head/><body><p><span style=\" font-size:10pt;\">Component</span></p></body></html>"))
self.comboBox_2.setItemText(0, _translate("MainWindow", "eComm"))
self.comboBox_2.setItemText(1, _translate("MainWindow", "workproc"))
self.pushButton.setText(_translate("MainWindow", "Search"))
self.groupBox.setTitle(_translate("MainWindow", "Other Details"))
self.radioButton.setText(_translate("MainWindow", "Only Search in Archive"))
self.radioButton_2.setText(_translate("MainWindow", "Also Search in Archive"))
self.checkBox.setText(_translate("MainWindow", "Auto Download"))
self.radioButton_3.setText(_translate("MainWindow", "Only Search in Log"))
self.label_3.setText(_translate("MainWindow", "<html><head/><body><p>Search String<span style=\" color:#ff0000;\">*</span></p></body></html>"))
## self.checkBox_2.setText(_translate("MainWindow", "CheckBox"))
## self.checkBox_3.setText(_translate("MainWindow", "CheckBox"))
## self.checkBox_4.setText(_translate("MainWindow", "CheckBox"))
## self.checkBox_5.setText(_translate("MainWindow", "CheckBox"))
## self.checkBox_6.setText(_translate("MainWindow", "CheckBox"))
self.menuhelp.setTitle(_translate("MainWindow", "Help"))
self.actionAbout.setText(_translate("MainWindow", "About"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())
as you can see the scroll area is not showing properly.i have some 20 servers to show.this server list is coming from ini file and i need to show the check boxes in that scroll area.
you need to use QLayout to arrange you widgets. check out
Qt Designer -> "Widget Box" docker -> "Layouts" section
For the scrollarea part:
create scrollarea scroll_area = QScrollArea()
create view widget you want to put inside scrollarea base_widget = QWidget()
install view layout for view widget base_layout = QVBoxLayout(base_widget)
install view widget into scrollarea scroll_area.setWidget(base_widget)
fill in objects with view layout base_layout.addWidget(QLabel('foo')) base_layout.addWidget(QPushButton('bar')) base_layout.addLayout(my_sub_layout) etc.

How to link my Kuthi.py file with my .xml file after clicking submit?

i have a python file which is designed using pyqt5 designer, i have .xml file which is the expected output, in this .xml file, there is spaces which will be replaced according to the desired input values?
like this, address will be in address location.
Here is my kuthi.py code:
# -*- coding: utf-8 -*-
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(800, 600)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.pushButton = QtWidgets.QPushButton(self.centralwidget)
self.pushButton.setGeometry(QtCore.QRect(190, 330, 75, 23))
self.pushButton.setObjectName("pushButton")
self.lineEdit_3 = QtWidgets.QLineEdit(self.centralwidget)
self.lineEdit_3.setGeometry(QtCore.QRect(200, 190, 261, 20))
self.lineEdit_3.setObjectName("lineEdit_3")
self.dateEdit = QtWidgets.QDateEdit(self.centralwidget)
self.dateEdit.setGeometry(QtCore.QRect(200, 260, 111, 22))
self.dateEdit.setObjectName("dateEdit")
self.label_4 = QtWidgets.QLabel(self.centralwidget)
self.label_4.setGeometry(QtCore.QRect(80, 230, 101, 16))
self.label_4.setObjectName("label_4")
self.label_2 = QtWidgets.QLabel(self.centralwidget)
self.label_2.setGeometry(QtCore.QRect(80, 170, 111, 16))
self.label_2.setObjectName("label_2")
self.lineEdit_4 = QtWidgets.QLineEdit(self.centralwidget)
self.lineEdit_4.setGeometry(QtCore.QRect(200, 230, 261, 20))
self.lineEdit_4.setObjectName("lineEdit_4")
self.label = QtWidgets.QLabel(self.centralwidget)
self.label.setGeometry(QtCore.QRect(80, 130, 81, 16))
self.label.setObjectName("label")
self.lineEdit = QtWidgets.QLineEdit(self.centralwidget)
self.lineEdit.setGeometry(QtCore.QRect(200, 130, 261, 20))
self.lineEdit.setObjectName("lineEdit")
self.label_5 = QtWidgets.QLabel(self.centralwidget)
self.label_5.setGeometry(QtCore.QRect(80, 260, 111, 16))
self.label_5.setObjectName("label_5")
self.label_3 = QtWidgets.QLabel(self.centralwidget)
self.label_3.setGeometry(QtCore.QRect(80, 200, 111, 16))
self.label_3.setObjectName("label_3")
self.lineEdit_2 = QtWidgets.QLineEdit(self.centralwidget)
self.lineEdit_2.setGeometry(QtCore.QRect(200, 160, 261, 20))
self.lineEdit_2.setObjectName("lineEdit_2")
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 21))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
self.pushButton.setText(_translate("MainWindow", "Submit"))
self.label_4.setText(_translate("MainWindow", "Enter Address :"))
self.label_2.setText(_translate("MainWindow", "Enter Father\'s Name :"))
self.label.setText(_translate("MainWindow", "Enter Full Name :"))
self.label_5.setText(_translate("MainWindow", "Enter Date of Birth :"))
self.label_3.setText(_translate("MainWindow", "Enter Mother\'s Name :"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())

PyQt5 identical push buttons, one works one doesn't

I tried writing some codes using pyqt5 and have two main windows and push buttons, for both cases I have done same but one works on clicked.connect and one doesn't. Pasting code for the button which doesn't work. I call this window after closing first one
I tried creating module outside of class and that worked but then struggled with referencing to lineEdit objects
from PyQt5 import QtCore, QtGui, QtWidgets
import sys
app = QtWidgets.QApplication(sys.argv)
PREMIX = QtWidgets.QMainWindow()
logo = QtGui.QIcon()
def init_login():
ui = Ui_PREMIXlogin()
ui.setupUi(PREMIX)
PREMIX.show()
sys.exit(app.exec_())
def close_login():
PREMIX.hide()
def init_main():
ui = Ui_PREMIX()
ui.setupUi(PREMIX)
PREMIX.show()
class Ui_PREMIXlogin(object):
def setupUi(self, PREMIXlogin):
PREMIXlogin.setObjectName("PREMIXlogin")
PREMIXlogin.setEnabled(True)
PREMIXlogin.resize(280, 319)
sizePolicy = QtWidgets.QSizePolicy(
QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed
)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(
PREMIXlogin.sizePolicy().hasHeightForWidth()
)
PREMIXlogin.setSizePolicy(sizePolicy)
PREMIXlogin.setMinimumSize(QtCore.QSize(280, 319))
PREMIXlogin.setMaximumSize(QtCore.QSize(280, 319))
PREMIXlogin.setMouseTracking(False)
PREMIXlogin.setWindowIcon(logo)
PREMIXlogin.setAutoFillBackground(False)
PREMIXlogin.setStyleSheet("background-color: rgb(255, 255, 255);")
self.centralwidget = QtWidgets.QWidget(PREMIXlogin)
self.centralwidget.setObjectName("centralwidget")
self.label = QtWidgets.QLabel(self.centralwidget)
self.label.setGeometry(QtCore.QRect(36, 190, 61, 20))
font = QtGui.QFont()
font.setPointSize(10)
self.label.setFont(font)
self.label.setObjectName("label")
self.label_2 = QtWidgets.QLabel(self.centralwidget)
self.label_2.setGeometry(QtCore.QRect(36, 220, 61, 20))
font = QtGui.QFont()
font.setPointSize(10)
self.label_2.setFont(font)
self.label_2.setObjectName("label_2")
self.lineEdit = QtWidgets.QLineEdit(self.centralwidget)
self.lineEdit.setGeometry(QtCore.QRect(110, 190, 113, 20))
self.lineEdit.setObjectName("lineEdit")
self.lineEdit_2 = QtWidgets.QLineEdit(self.centralwidget)
self.lineEdit_2.setGeometry(QtCore.QRect(110, 220, 113, 20))
font = QtGui.QFont()
font.setBold(True)
font.setWeight(75)
self.lineEdit_2.setFont(font)
self.lineEdit_2.setInputMethodHints(
QtCore.Qt.ImhHiddenText
| QtCore.Qt.ImhNoAutoUppercase
| QtCore.Qt.ImhNoPredictiveText
| QtCore.Qt.ImhSensitiveData
)
self.lineEdit_2.setFrame(True)
self.lineEdit_2.setEchoMode(QtWidgets.QLineEdit.Password)
self.lineEdit_2.setObjectName("lineEdit_2")
self.pushButton = QtWidgets.QPushButton(self.centralwidget)
self.pushButton.setGeometry(QtCore.QRect(100, 260, 81, 31))
font = QtGui.QFont()
font.setPointSize(11)
font.setBold(False)
font.setWeight(50)
self.pushButton.setFont(font)
self.pushButton.setAutoFillBackground(False)
self.pushButton.setStyleSheet("background-color: rgb(222, 31, 38);")
self.pushButton.setObjectName("pushButton")
self.frame = QtWidgets.QFrame(self.centralwidget)
self.frame.setGeometry(QtCore.QRect(30, 20, 231, 151))
self.frame.setStyleSheet(
"image: url(:/images/59301307_2353273704903079_3349139235981492224_n.png);"
)
self.frame.setFrameShape(QtWidgets.QFrame.StyledPanel)
self.frame.setFrameShadow(QtWidgets.QFrame.Raised)
self.frame.setObjectName("frame")
PREMIXlogin.setCentralWidget(self.centralwidget)
self.statusbar = QtWidgets.QStatusBar(PREMIXlogin)
self.statusbar.setObjectName("statusbar")
PREMIXlogin.setStatusBar(self.statusbar)
self.retranslateUi(PREMIXlogin)
QtCore.QMetaObject.connectSlotsByName(PREMIXlogin)
def retranslateUi(self, PREMIXlogin):
_translate = QtCore.QCoreApplication.translate
PREMIXlogin.setWindowTitle(_translate("PREMIXlogin", "PREMIX Login"))
self.label.setText(_translate("PREMIXlogin", "Username"))
self.label_2.setText(_translate("PREMIXlogin", "Password"))
self.pushButton.setText(_translate("PREMIXlogin", "Log in"))
self.pushButton.clicked.connect(self.on_click)
def on_click(self):
if True:
close_login()
init_main()
class Ui_PREMIX(object):
def setupUi(self, PREMIX):
PREMIX.setObjectName("PREMIX")
PREMIX.resize(473, 179)
sizePolicy = QtWidgets.QSizePolicy(
QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed
)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(PREMIX.sizePolicy().hasHeightForWidth())
PREMIX.setSizePolicy(sizePolicy)
PREMIX.setMinimumSize(QtCore.QSize(473, 179))
PREMIX.setMaximumSize(QtCore.QSize(473, 179))
PREMIX.setStyleSheet("background-color: rgb(255, 255, 255);")
PREMIX.setWindowIcon(logo)
self.centralwidget = QtWidgets.QWidget(PREMIX)
self.centralwidget.setObjectName("centralwidget")
self.Product = QtWidgets.QLabel(self.centralwidget)
self.Product.setGeometry(QtCore.QRect(30, 20, 61, 20))
font = QtGui.QFont()
font.setPointSize(13)
self.Product.setFont(font)
self.Product.setObjectName("Product")
self.Productname = QtWidgets.QLineEdit(self.centralwidget)
self.Productname.setGeometry(QtCore.QRect(100, 20, 251, 20))
self.Productname.setObjectName("Productname")
self.Checkbutton = QtWidgets.QPushButton(self.centralwidget)
self.Checkbutton.setGeometry(QtCore.QRect(370, 20, 81, 21))
font = QtGui.QFont()
font.setPointSize(11)
font.setBold(False)
font.setWeight(50)
self.Checkbutton.setFont(font)
self.Checkbutton.setAutoFillBackground(False)
self.Checkbutton.setStyleSheet("background-color: rgb(222, 31, 38);")
self.Checkbutton.setObjectName("Checkbutton")
self.logo = QtWidgets.QFrame(self.centralwidget)
self.logo.setGeometry(QtCore.QRect(359, 60, 101, 80))
self.logo.setStyleSheet(
"image: url(:/images/59301307_2353273704903079_3349139235981492224_n.png);"
)
self.logo.setFrameShape(QtWidgets.QFrame.StyledPanel)
self.logo.setFrameShadow(QtWidgets.QFrame.Raised)
self.logo.setObjectName("logo")
self.lineEdit = QtWidgets.QLineEdit(self.centralwidget)
self.lineEdit.setGeometry(QtCore.QRect(180, 80, 91, 31))
self.lineEdit.setMinimumSize(QtCore.QSize(89, 31))
self.lineEdit.setMaximumSize(QtCore.QSize(91, 31))
self.lineEdit.setObjectName("lineEdit")
self.lineEdit.setReadOnly(True)
PREMIX.setCentralWidget(self.centralwidget)
self.statusbar = QtWidgets.QStatusBar(PREMIX)
self.statusbar.setObjectName("statusbar")
PREMIX.setStatusBar(self.statusbar)
self.retranslateUi(PREMIX)
QtCore.QMetaObject.connectSlotsByName(PREMIX)
def retranslateUi(self, PREMIX):
_translate = QtCore.QCoreApplication.translate
PREMIX.setWindowTitle(_translate("PREMIX", "PREMIX"))
self.Product.setText(_translate("PREMIX", "Product"))
self.Checkbutton.setText(_translate("PREMIX", "Check"))
self.Checkbutton.clicked.connect(self.on_click)
def on_click(self):
print("aaaaaa")
product = self.Productname.text()
print(product)
def main():
init_login()
if __name__ == "__main__":
main()
I want Checkbutton on click event to work, please help
For Ui_Premix, used self.Checkbutton.clicked.connect(Ui_PREMIX.on_click) instead of
self.on_click even though on_click event was inside class, it works now

Can't print a LineEdit value in python

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 QStrings, 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 QStrings, print them as follows
print("%s\n%s" % log,passw)

Categories

Resources