[pygtk] TreeView and CellRendererCombo - MS Access-like form behaviour

Stéphane Brunet stbru at teksavvy.com
Sun Apr 20 01:16:41 WST 2008


Hi,

btw, thank you John Finlay for the answer on my last question.

In my quest of a GUI interfacing my small database application (I did 
try OpenOffice Base and went mad after one hour :S ) I would like to 
copy some behaviour of MS Access in my forms.

Say I have two (SQL) tables with two fields and one relation between the 
two:

----------------      ----------------
|    Table1    |      |    Table2    |
----------------      ----------------
| Field1 (int) |<---->| Field1 (int) |
| Field2 (str) |      | Field2 (str) |
----------------      ----------------

Now in my PyGTK form of Table1 (a TreeView), when I display the Field1 
in the first column, I would like to have a ComboBox which displays the 
text associated to the integer value of Table2 (i.e. Table2.Field2) 
rather than the value directly. However, I still want it stored as an 
integer in Table1.Field1.

How would you do this in an elegant manner ? Do I have to create my own 
CellRenderer more generic than a CellRendererCombo ?

Thanks again,

Stéphane



More information about the pygtk mailing list