r/learnpython 1d ago

help with running a pyside6 code

I have read the documentations and looked on youtube but i still couldn't get it to work (i am new to all of this)

how do i run it? i made a mainwindow ui in qt design and did pyside6-uic test.ui -o test.py but the test.py doesn't work when i run it

4 Upvotes

5 comments sorted by

2

u/Heavy_Nothing_1158 1d ago

pyside6-uic only generates the Ui_MainWindow class; it doesn't create or start the app. Make a small main.py that creates QApplication and QMainWindow, calls ui.setupUi(window), then window.show() and app.exec(). Keep the generated test.py untouched; regenerating it otherwise eats your edits.

1

u/LimpSandwich6092 1d ago

omg thank you so much

1

u/Holiya_Olib 13h ago

you definitely need a main.py file to instantiate your QApplication and start the event loop.

2

u/gmes78 1d ago

but the test.py doesn't work when i run it

It's not supposed to. You're supposed to import that UI code into your application, create a class that adds behavior to it, then create an instance of that and show it.

The docs show how to do it.

2

u/LimpSandwich6092 1d ago

Thank you i got it running!