how i'm supposed to internally structure my project with Qt?
-
hi!
idk how i'm supposed to internally structure my program using the Qt framework,in my actual case i have 3 files:-
ui_Def.py
-
ui_Main.py
Main.py:
here i have the basic stuff:imports.... class MainWindow(QMainWindow): def __init__(self): QMainWindow.__init__(self) self.ui = Ui_MainWindow() self.ui.setupUi(self). self.show() if __name__ == "__main__": app = QApplication(sys.argv) window = MainWindow() sys.exit(app.exec_())
ui_Def.py:
it has all the def´s that gives the gui functionality(i guess?), for example:a_button_in_the_ui.clicked.connect(lambda: module_that_does_something(self))
my problem it's when i do something, where the module should be?, in an app_Def.py for example?
or maybe all this is nonsense and that's not the standard way to organize stuff?
ui_Main.py:
that's the .py generated by QDesigner(it has the Ui_MainWindow class)Thanks!
-
@adrian88888888
I don't understand what is in/the purpose of yourui_Def.py
?a_button_in_the_ui.clicked.connect(lambda: module_that_does_something(self))
How are you gaining access to
a_button_in_the_ui
? I would just expect this to be inMainWindow
, where you can goself.ui.the_button.clicked.connect(...)
?Then if you want that clicked slot code to be elsewhere in another module/file, that's fine. Whether it should need a parameter of
self
is not so clear, why do you need to pass theMainWindow
instance off to somewhere? In general, you don't want that other something module to be accessing things back in the main window.... -
@JonB
i placed the:a_button_in_the_ui.clicked.connect(lambda: module_that_does_something(self))
not inside the MainWindow instance because there are lots of those connections, and there's more stuff in reality, and it's becoming a total mess, that why im in problems with how to organize internally, the instance its getting full of different stuff
yes, the self part i got no idea yet
yes i know it doesn't make sense, what should i do? what would you do in my case?
Thanks btw for helping me