OO design, Python, and GUIs

Christopher Culver christopher_culver_ForiguCxiTion at yahoo.com
Tue Nov 18 00:16:32 EST 2003


I'm creating a home-library management program with Python 2.2, PyGTK, and
Glade. While I've been many little programs before, this is my first large
application in Python. My question is how I should organise the OO design
of such a program. There should be, I gather, a core class "MainClass",
which coordinates everything, other specialised classes which report to
MainClass, and the GUI should ideally be in its own class "GuiClass".

Now GuiClass at the moment doesn't know anything about MainClass. When the
program is started, an instance "mainClass" is created, which in turn
creates an instance "guiClass". But how can guiClass report anything to
the mainClass? For example, when the user selects a new file in the GUI,
how can I send the chosen pathname to mainClass?

I imagine that I have to initalise the GuiClass instance in such a way
that it knows about mainClass enough to be able to call its methods, but
I've been unable find out how mainClass could pass itself to the GuiClass
__init__.

Be gentle, I'm somewhat of a newbie. If there's documentation out there on
this, I'll happily take a look.

Christopher Culver




More information about the Python-list mailing list