Answer the question
In order to leave comments, you need to log in
How to get the result and display it in another window?
I have a window in which I enter the name of the SQL table from which I want to get data. Then another window opens with a "Result" button and a TextLabel where the result should be displayed. By clicking on the "Result" button, I get the error "Process finished with exit code -1073740791 (0xC0000409)". How to fix it?
class Ui_Window1_results(object):
def setupUi(self, Window1_results):
Window1_results.setObjectName("Window1_results")
Window1_results.resize(401, 579)
Window1_results.setStyleSheet("background-color: rgb(0, 85, 127);")
self.centralwidget = QtWidgets.QWidget(Window1_results)
self.centralwidget.setObjectName("centralwidget")
self.output = QtWidgets.QLabel(self.centralwidget)
self.output.setGeometry(QtCore.QRect(6, 102, 391, 371))
font = QtGui.QFont()
font.setPointSize(10)
self.output.setFont(font)
self.output.setStyleSheet("background-color: rgb(255, 255, 255);")
self.output.setObjectName("output")
self.info_table = QtWidgets.QLabel(self.centralwidget)
self.info_table.setGeometry(QtCore.QRect(90, 30, 231, 41))
font = QtGui.QFont()
font.setPointSize(15)
self.info_table.setFont(font)
self.info_table.setStyleSheet("background-color: rgb(255, 255, 255);")
self.info_table.setObjectName("info_table")
self.ready = QtWidgets.QPushButton(self.centralwidget)
self.ready.setGeometry(QtCore.QRect(140, 530, 111, 31))
font = QtGui.QFont()
font.setPointSize(15)
self.ready.setFont(font)
self.ready.setStyleSheet("background-color: rgb(255, 255, 255);")
self.ready.setObjectName("ready")
Window1_results.setCentralWidget(self.centralwidget)
self.retranslateUi(Window1_results)
QtCore.QMetaObject.connectSlotsByName(Window1_results)
# если нажата кнопка "Результат" или же "ready", вызовется функция "Window1_results"
self.ready.clicked.connect(self.window1_results)
def retranslateUi(self, Window1_results):
_translate = QtCore.QCoreApplication.translate
Window1_results.setWindowTitle(_translate("Window1_results", "MainWindow"))
self.output.setText(_translate("Window1_results", "TextLabel"))
self.info_table.setText(_translate("Window1_results", "id-Оценка-Комментарий"))
self.ready.setText(_translate("Window1_results", "Результат"))
def window1_results(self):
# получение названия таблицы, который ввел пользователь в предыдущем окне
self.table = self.textEdit.toPlainText()
# получение данных из этой таблицы
self.mySQLQuery = (f'''
SELECT id, {self.table}, Комментарий
FROM dbo.{self.table}
''')
self.cursor.execute(self.mySQLQuery)
self.results = self.cursor.fetchall()
self.mySQLQuery2 = (f'''
SELECT {self.table}
FROM dbo.{self.table}
''')
self.cursor.execute(self.mySQLQuery2)
self.results2 = cursor.fetchall()
# вывод полученных данных в TextLabel
self.output.setText(self.results)
self.output.adjustSize()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question