-1

I created gui with qt editor and ı transform to py file but when ı try change label nothing happens. My Code:

import sqlite3
from PySide6.QtWidgets import QApplication, QWidget
import sys
import random
from ui_form import Ui_Widget
class Widget(QWidget):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.ui = Ui_Widget()
        self.ui.setupUi(self)
if __name__ == "__main__":
    app = QApplication(sys.argv)
    widget = Widget()
    widget.show()
    sys.exit(app.exec())
conn=sqlite3.connect("englishwords.db")
cursor=conn.execute("select*from words ")
x=0;
y=0;
truecount=0
falsecount=0
Widget().ui.question.setText("c")
x=random.randrange(1,100)
conn.close()

I try this code:

QtCore.QCoreApplication.processEvents()
LordKurtu
  • 1
  • 2
  • Typos. Move the last lines (from `conn` to the end) in the `if` block and *before* `sys.exit()`. Also, change to `widget.ui.question.setText("c")`. Note that `sys.exit()` tells the python interpreter to quit, that's why those lines are never executed. Also, even if it worked, doing `Widget().ui.question.setText("c")` is both pointless and wrong, since it creates a *new* instance of the widget (while you want to change the existing one) and doesn't keep any reference to that anyway. I strongly suggest you to read more about classes and instances. – musicamante Aug 30 '23 at 17:13
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Aug 30 '23 at 19:13

0 Answers0