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

John Finlay finlay at moeraki.com
Mon Apr 21 02:13:11 WST 2008


Stéphane Brunet wrote:
> 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 ?
How do you want the db info displayed in the treeview? Are you planning 
on inserting the
 table info into a liststore or generating it on the fly?

John


More information about the pygtk mailing list