Proper layout of python packages for a Graphical User Interface (GUI)

156 Views Asked by At

On the project I'm currently working on (a GUI for a testing system) I'm required to write base classes for all graphical objects and inherit these objects into the class which utilises the graphical object. The actual working code is then written there. This seems like standard procedure for these sort of GUI related projects.

My question is; with multiple graphical object base files, all inherited by functional modules, which are all executed by a mainframe module which is launched by a Launcher script, are there any recommended layouts for the file system containing these scripts.

I'm basically deciding between:

/mainfolder ---> __init__.py
                 launcher.py
                 /MainPackage ---> __init__.py
                                  Mainframe.py
                                  Subframe_1.py
                                  Subframe_2.py
                                  /Bases ------> __init__.py
                                                 Mainframe_base.py
                                                 Subframe_1_base.py
                                                 Subframe_2_base.py

or :

/mainfolder ---> __init__.py
                 launcher.py
                 /MainPackage ---> __init__.py
                                   /Mainframe    ---> __init__.py
                                                      Mainframe.py
                                                      Mainframe_base.py
                                   /Subframe_1.py --> __init__.py
                                                      Subframe_1.py
                                                      Subframe_1_base.py
                                   /Subframe_2.py --> __init__.py
                                                      Subframe_2.py
                                                      Subframe_2_base.py

Are either of these better than the other? Or is there another, more commonly used form of organising the modules?

1

There are 1 best solutions below

1
On BEST ANSWER

I like to keep things modular, so would go with

/mainfolder --> __init__.py
                launcher.py
                /MainPackage --> __init__.py
                                 /Mainframe  --> __init__.py
                                                 Mainframe.py
                                                 Mainframe_base.py
                                 /Subframe_1 --> __init__.py
                                                 Subframe_1.py
                                                 Subframe_1_base.py
                                 /Subframe_2 --> __init__.py
                                                 Subframe_2.py
                                                 Subframe_2_base.py

if not just 1 .py per frame.