trouble setting up TreeViews in pygtk

Posted by Chris H on Stack Overflow See other posts from Stack Overflow or by Chris H
Published on 2010-05-08T13:44:30Z Indexed on 2010/05/08 13:48 UTC
Read the original article Hit count: 170

Filed under:
|
|
|

I've got some code in a class that extends gtk.TreeView, and this is the init method. I want to create a tree view that has 3 columns. A toggle button, a label, and a drop down box that the user can type stuff into. The code below works, except that the toggle button doesn't react to mouse clicks and the label and the ComboEntry aren't drawn. (So I guess you can say it doesn't work). I can add rows just fine however.

    #make storage                   enable/disable  label    user entry
    self.tv_store = gtk.TreeStore(gtk.ToggleButton, str, gtk.ComboBoxEntry)
    #make widget
    gtk.TreeView.__init__(self, self.tv_store)
    #make renderers
    self.buttonRenderer = gtk.CellRendererToggle()
    self.labelRenderer = gtk.CellRendererText()
    self.entryRenderer = gtk.CellRendererCombo()
    #make columns

    self.columnButton = gtk.TreeViewColumn('Enabled')
    self.columnButton.pack_start(self.buttonRenderer, False)
    self.columnLabel = gtk.TreeViewColumn('Label')
    self.columnLabel.pack_start(self.labelRenderer, False)
    self.columnEntry = gtk.TreeViewColumn('Data')
    self.columnEntry.pack_start(self.entryRenderer, True)

    self.append_column(self.columnButton)
    self.append_column(self.columnLabel)
    self.append_column(self.columnEntry)

    self.tmpButton = gtk.ToggleButton('example')
    self.tmpCombo = gtk.ComboBoxEntry(None)
    self.tv_store.insert(None, 0, [self.tmpButton, 'example label', self.tmpCombo])

thanks.

© Stack Overflow or respective owner

Related posts about python

Related posts about pygtk