On Tue, 29 Oct 2002 16:31:34 -0600 (CST)
Tanya Brethour <[EMAIL PROTECTED]> wrote:

> 
> Ok. I am a newbie to gtk and python.. please do not let that scare you
> aware :)
> 
> Essentially I have a ctree currently with many nodes in it. I want to be
> able to "check" certain nodes. So I would have the label and a small
> checkbox next to it. So the user can check certain items they want and
> leave the ones they don't unchecked. Make sense? 
> 
> So.. I saw some messages on this list dating back to Nov. 2001 in
> regards to Ctree and Checkboxes and it did not look promising. From the
> pygtk tutorial.. I did not really find an answer. As far as I can tell
> ctree only lets you specify a open and closed image.

Well, if you are creative enough, you can just fake it using pixmaps.

(When I use 'tree' I refer to the specific ctree you are dealing with)

Let's say you have a dictionary of settings, like this:

    self.pixmaps = {}
    self.pixmaps['On'] = gtk.create_pixmap_from_xpm(tree, None, 'On.xpm')
    self.pixmaps['Off'] = gtk.create_pixmap_from_xpm(tree, None, 'Off.xpm')

you build the tree with:

        columns = [some text here]

(for nodes):      
        node = 
tree.insert_node(parent,None,columns,5,None,None,None,None,gtk.TRUE,gtk.FALSE)

(for branches):
        node = 
tree.insert_node(parent,None,columns,5,None,None,None,None,gtk.FALSE,gtk.FALSE)

and on each of them you call (setting is either 'On' or 'Off'):
(this is a function):

    (xpm,xpm_mask) = self.pixmaps[setting]
    col = 1
    tree.node_set_text(node,0,setting)
    (bleh,bleh,bleh,bleh,bleh,bleh,is_leaf,expanded) = tree.get_node_info(node)
    tree.set_node_info(node, setting, 5, xpm, xpm_mask, xpm, xpm_mask, is_leaf, 
expanded)

neat!

Now, when you want to "update" the pixmap as a result of some
user or programmatic action, you just do the same thing again (above)
with the appropriate setting.

See?

-- 
Pound for pound, the amoeba is the most vicious animal on earth.

Jon Nelson <[EMAIL PROTECTED]>
C and Python Code Gardener
_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to