Structuring a Large PyQt Application

Heads up! You've already completed this tutorial.

tcarson4344 | 2020-05-25 20:27:19 UTC | #1

I am an NVH Engineer and I am learning Python. Historically I have used Labview and other commercial software in my work life. I like that there is so much work that has been done developing code for NVH analysis in python.

I would like to make open-source GUI applications that can harness a lot of the work that has been done. The first thing I want to tackle is a Time Data Recorder application. functionally it would operate similarly to this commercial product.

HDF5 - Data Storage pyacq - Possible acquisition framework GUI - Develop in PySide2

I was thinking about something like this for gui skeleton image|690x474, 50%

and this for the TDR App inside it image|690x472, 50%

I am looking for some help with directory and software structure. I have the main layout working in code (buttons don't do anything yet). Any thought would be helpful

Packaging Python Applications with PyInstaller by Martin Fitzpatrick — This step-by-step guide walks you through packaging your own Python applications from simple examples to complete installers and signed executables.

More info Get the book

Timm


Eolinwen | 2020-05-26 14:45:35 UTC | #2

Hi tcarson4344

Indeed, it is a large PyQt application that you plan to design. :wink:

Personally, I can give a part of answer because, even I have planned to make a big (for me) application in another domain than you, I have studied a bit the question.

On the left part, you'll need a QListWidget and on the right part a QStackedWidget and probably a QStackedLayout. This latter is not sure. A bit like this.

[url=http://pix.toile-libre.org/?img=1590507878.png][/url]

About the structure, usually I used this one: (after it is done for Linux only) I don't know for Macos and Windwos.

For the root package (i.e the folder of the application herself), I introduce a start_app file (which run the application) and share files in different folders according to their membership ui, translations, window etc ...

This thread on Stackoverflow will be helpful for you. You have even a project structure proposed.

I hope that will help you.


tcarson4344 | 2020-05-26 22:42:46 UTC | #3

@Eolinwen,

Thank you this is helpful. Does something like this seem reasonable?

python
├── main.py
├── ui_main.py
├── Modules
│   ├── Time_Data_Recorder
│   │   ├── TDR.py
│   │   ├── ui_TDR.py
│   ├── Spectral_Testing
│   └── Other_Modules
└── Third_Party_libraries
    ├── HDF5
    ├── Pyacq
    ├── Plotting
    └── Other

Eolinwen | 2020-05-27 14:58:20 UTC | #4

Hum. Like it is a large App, and with the result that you want, I 'll create a sub-folder (like Modules folder) for ui files at least. You should cut your code if you don't want to be overflow. And if you add views.....

I suggest that you 'll take a look at the structure of Openshot-qt. Even it is not in the same domain, it is a large project (Video Editor) and with the Stackoverflow structure they will correspond more at that you want to get.

And use uic for loading ui files.........but be careful for memory foot.


Create GUI Applications with Python & Qt6 by Martin Fitzpatrick — (PyQt6 Edition) The hands-on guide to making apps with Python — Over 10,000 copies sold!

More info Get the book

Well done, you've finished this tutorial! Mark As Complete
[[ user.completed.length ]] completed [[ user.streak+1 ]] day streak

Structuring a Large PyQt Application was written by Martin Fitzpatrick .

Martin Fitzpatrick has been developing Python/Qt apps for 8 years. Building desktop applications to make data-analysis tools more user-friendly, Python was the obvious choice. Starting with Tk, later moving to wxWidgets and finally adopting PyQt.