suggestions on code structuring? (classes; gui, data, methods...)

Vlastimil Brom vlastimil.brom at gmail.com
Wed May 14 20:00:33 EDT 2008


Hi all;
I'd like to ask for suggestions regarding the appropriate structure of the
code of my app. It is a gui program (wxPython; wx.aui) displaying several
texts simultaneously. The user interface consists of multiple text widgets
and control panels for selecting the text parts and synchronising.
Basically the program reads several text files, analyses them, displays them
in the text controls and keeps track of some aditional indexing information
(used for synchronising the text with each other etc.

What would be an usual way of structuring the code? I tried to separate
distinct tasks to classes, but I am not sure, if this is the right way:
Currently I have a TextDB class containing the functions to parse the source
text, then it stores the resulting fulltext, the indexing data; it also
contains lookup methods for the text properties and also a display method
(expecting a gui widget to write into). There is one instance of this class
associated with each text.
Further there is an instance of a gui class (subclassing the wx.Panel -
TextCtrl and some basic controls) for each text; besides this there are also
panels with specific settings/selections of the individual texts. All this
is managed in a frame using wx.aui.AuiManager (the panes can be moved or
hidden, but in general, there might be over a dozen of panels used
simultaneously on the screen).

Now, what would be a standard approach to let the single instances
comunicate with each other? Is it usual, that the "data" instances are
created by the gui instances (or the main program class)? Or would
it be better to create an extra "dispatch" class communicating with the
others? (Here e.g. the user can select some text-property in the control
panel, this value is then checked in the respective TextDB instance; finally
the matching text part is shown in the text widget.)
Unfortunately, I couldn't find many relevant code examples or general
informations; actualy many tutorial etc. gui programs often have ratner few
classes, sometimes the only one.

Any suggestions, or references to some examples, concepts ... are much
appreciated;
thanks in advance;
      Vlasta
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080515/d5fb9758/attachment.html>


More information about the Python-list mailing list