Fast loading of complex interfaces
-
Hi there
I'm new to PySide so if I've missed any important information - please let me knowI have created a large and complex application interface through
pyside6-designer
. I got a.ui
file with more than 15,000 lines. When converting throughpyside6-uic
I get a single.py
file where all widgets are set in a singlesetupUi
function.Problem: When calling
setupUi
function in my code, my application freezes for 1-2 sec.Questions:
- Is there an alternative to
pyside6-uic
in the PySide ecosystem that would use lazy loading? - Maybe I am missing some parameters when using
pyside6-uic
? - What approach do you recommend to quickly load complex interfaces made via
pyside6-designer
?
Dividing a
.ui
file into smaller ones is highly undesirable. In the future I would like to edit the whole interface inpyside6-designer
at once.Thanks
- Is there an alternative to
-
@Quew Design your app in a way that it does not have to show everything at once. Then create ui files for different parts of the interface. At runtime instantiate only what is active and should be shown. Widgets can be instantiated at runtime when needed, you do not have to create them all at start up.
-
The problem is not the number of lines in your
.ui
file. The problem is with the number of widgets (buttons, line edits, etc.). Creating all those widgets is what is slow. It is highly unlikely that all of this fits on the screen at the same time. You need to write some smart logic to create only the widgets that are visible. This also means to switch from the Qt Designer to writing everything as Python code instead.I have a little story: We have a visualization software that could load several data sets from a project file. For each data set we would have a settings dialog. We thought it would be a smart idea to instantiate all the dialogs right at the beginning when loading the project. This way, the user would never have to wait for a settings dialog to open for the first time (even though this is already sufficiently fast). We had to drop that idea because startup would be quite slow as in your case.
Moral of the story: If you have dialogs, stacked widgets, tabs, then put these in separate
.ui
files and load them when the stacked widget, tab is selected. There is no other way. -
@SimonSchroeder said in Fast loading of complex interfaces:
This also means to switch from the Qt Designer to writing everything as Python code instead.
I disagree: you can still design ui widgets for different parts of the user interface using designer. You just have to split the big ui file into several smaller files and only instantiate what is needed.
-
@Quew
I agree with the others that you should split or delay somehow. 1 to 2 seconds loading indicates you have a lot of stuff going on in there. Don't forget you can look at theuic
-generated.py
file to see what it does, it's just plain Python, you can even step through it line by line in debugger.Just one thing: let's say you leave it as-is because you don't want to divide it for whatever reason. Are you at least aware that Qt has a QSplashScreen? This is intended to show to the user on start up, usually while you do back end time consuming tasks but could be used here if you want the user to see something other than "freeze".
-
@JonB said in Fast loading of complex interfaces:
Just one thing: let's say you leave it as-is because you don't want to divide it for whatever reason. Are you at least aware that Qt has a QSplashScreen?
Didn't know that. I'll use it. tnx
@jsulm said in Fast loading of complex interfaces:
you can still design ui widgets for different parts of the user interface using designer.
I think I'll do what you wrote. Thank you.
-