def retranslateUi(self, MainWindow, city_name, city_s_name, type_of_government, attitude_to_magic, level_of_technology, natural_area, short_info):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
self.l_city_name.setText(_translate("MainWindow", f"{city_name}"))
self.l_city_s_name.setText(_translate("MainWindow", f"{city_s_name}"))
self.l_city_edit_info_1.setText(_translate("MainWindow", f"{type_of_government}"))
self.l_city_edit_info_2.setText(_translate("MainWindow", f"{attitude_to_magic}"))
self.l_city_edit_info_4.setText(_translate("MainWindow", f"{level_of_technology}"))
self.l_city_edit_info_3.setText(_translate("MainWindow", f"{natural_area}"))
self.l_city_edit_info_5.setText(_translate("MainWindow", f"{short_info}"))
city = sq.get_city_info(2)
self.retranslateUi(MainWindow, city[1], city[2], city[3], city[4], city[5], city[6], city[7])
def get_city_info(city_id: int):
cmd = "SELECT * FROM cities_info WHERE id = %d" % city_id
c.execute(cmd)
result = c.fetchone()[0]
return result
Process finished with exit code -1073740791 (0xC0000409)
from PyQt5 import QtCore, QtGui, QtWidgets
import sys
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(406, 240)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.label = QtWidgets.QLabel(self.centralwidget)
self.label.setGeometry(QtCore.QRect(50, 40, 251, 41))
self.label.setObjectName("label")
MainWindow.setCentralWidget(self.centralwidget)
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.label.setText(_translate("MainWindow", "TextLabel"))
class bb():
def __init__(self, signal):
signal.emit("Я здесь что то поменял\n и отправил в основной поток")
class main(QtWidgets.QMainWindow, Ui_MainWindow):
signal = QtCore.pyqtSignal(str)
def __init__(self, parent=None):
super().__init__()
QtWidgets.QMainWindow.__init__(self)
self.setupUi(self)
self.signal.connect(self.text, QtCore.Qt.QueuedConnection)
bb(self.signal)
def text(self, text):
self.label.setText(text)
if __name__ == '__main__':
app = QtWidgets.QApplication(sys.argv)
MainWindow = main()
MainWindow.show()
sys.exit(app.exec_())
def start_city_bilgewater_info(self):
self.ui_city_info.setupUi(self, "BILGEWATER_BACK", "BILGEWATER_BACKGROUND", "BILGEWATER_3D")
self.ui_city_info.pb_cancel_city_info.clicked.connect(self.start_map)
with sqlite3.connect('database/database.db') as db:
cursor = db.cursor()
cursor.execute("SELECT * FROM cities_info WHERE id = %d" % 2)
result = cursor.fetchone()
self.ui_city_info.l_city_name.setText(str(result[1]))
self.ui_city_info.l_city_s_name.setText(str(result[2]))
self.ui_city_info.l_city_edit_info_1.setText(str(result[3]))
self.ui_city_info.l_city_edit_info_2.setText(str(result[4]))
self.ui_city_info.l_city_edit_info_3.setText(str(result[6]))
self.ui_city_info.l_city_edit_info_4.setText(str(result[5]))
self.ui_city_info.l_city_edit_info_5.setText(str(result[7]))
cursor.close()
db.close()
self.show()