How could I make a good application architecture in Python with PyQt? -
i think appication doesn't have architecture. can't figure out how navigate between files correctly.
here non-standardized schema of application.

each file contains 1 class.
the principal problem can't variables class because of architecture of code. if put classes in 1 file, runs want separate classes (which qwindowand qwidget) in several files.
1. in every parent class, import each child :
from childfilename import childclassname for example, in optionwindow class, have :
from mainwindowfilename import mainwindowclassname toolbarfilename import toolbarsclassname menubarfilename import menubarclassname note 1 : better lisibility, name files same name classes. *for example : mytoolbar.py contains class mytoolbar(qtgui.qtoolbar)*
note 2 : need place empty __init__.py in every folder contains class)
note 3 : can place classes in different folders. if so, use :
from folder.childfilename import childclassname 2. instantiate , call child functions or child variables :
in parent class :
self.child1=childclassname() self.child1.childfunction1() a1 = self.child1.childvariable1 in child class :
... self.childvariable1 = 2 def childfunction1(self): ... 3. parent or grand-parents variables or functions in child : in parent class :
... self.parentvariable1 = 2 def parentfunction1(self): ... in child class :
self.parent().parentfunction1()` a1 = self.parent().parentvariable1` note : self.parent().parent(). ... grand parent.
i hope helped
Comments
Post a Comment