OO menu management

Egbert Bouwman egbert.list at hccnet.nl
Tue Aug 10 11:37:30 EDT 2004


I have difficulties in organizing my menus, especially in linking
them to the underlying application logic.

I try to follow the OO rules:
the gui classes, in their own module gui.py, do the gui work,
in my case with pygtk, 
and they know nothing about the application logic in app.py.

So a button in the gui starts a callback that in realty is a method
in app.py, and the name of that callback is given to the gui 
via an argument. That works well for a single button.

With a menu system it is different, because there are so many buttons.

I still have for each menu button:
- a callback-name variable in the gui class
- a real callback method in the application class
and now a dictionary that links those two.  
That dictionary is argument-passed to the gui.

Additionally in the gui itself I have a nested list with for each button:
- the name of the menu button (MenuItem) itself
- the name of the sub-menu it belongs to
- the tekst on the button
- the sub-menu it may open
- the name of its callback (
- the callback arguments

It is quite complex, with a lot of correspondences that may go wrong.
So I wonder if my approach is the right one.
Do I understand the OO approach well ?
Should I relax the OO guidelines ?
Is there something in python which may help, but which I have overlooked ?

egbert
-- 
Egbert Bouwman - Keizersgracht 197 II - 1016 DS  Amsterdam - 020 6257991
========================================================================



More information about the Python-list mailing list