[pygtk] combobox question

Casey McGinty casey.mcginty at gmail.com
Fri Jul 4 11:37:45 WST 2008


On Wed, Jul 2, 2008 at 10:32 PM, Casey McGinty <casey.mcginty at gmail.com>
wrote:

> On Tue, Jul 1, 2008 at 11:23 AM, Chris Cole <ccole2 at mix.wvu.edu> wrote:
>
>> Hey all,
>> I have a simple combobox that i've created with glade. I was just
>> wondering if i could set the sensitivity of the individual elements in
>> the combobox? like setting a widget set_sensitive(False) ?
>
>
> I think you can set the 'sensitive' property of the CellRendererText
> instance stored in the the ComboBox instance. I believe you can use the
> get_cells() method to access the instance. However, I'm not sure if there=
 is
> a dedicated CellRendereText instance for each row. Let me know if that he=
lps
> as I'm still trying to learn as well.
>
> - Casey
>

Following up, I think you have to add a boolean 'sensitive' column to the
gtk.ListStore model of the gkt.ComboBox. Then associate the 'sensitive'
column with the 'sensitive' property of the CellRenderText instance using
the 'add_attribute' method.

For example:

# assuming combo box model has a text value (col 0) and boo sensitive value
(col 1)
combo_box.add_attribute( cell, 'sensitive', 1 )

You can get more info about associating cell render attribute here:
http://www.pygtk.org/pygtk2tutorial/sec-CellRenderers.html#sec-CellRenderer=
Attributes

- Casey
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.daa.com.au/pipermail/pygtk/attachments/20080703/22c89694/at=
tachment.htm


More information about the pygtk mailing list