0

我在pygtk中有以下代码:

....
    rendererText = gtk.CellRendererText()
    self.columns["hour"] = gtk.TreeViewColumn("Uur", rendererText, text=0)
    self.columns["hour"].set_sort_column_id(0)   
    self.treeview.append_column(self.columns["hour"])

    self.columnControls["ond"] = gtk.CellRendererToggle()
    self.columns["ond"] = gtk.TreeViewColumn("ond", self.columnControls["ond"], active=1)
    self.columns["ond"].set_sort_column_id(1)   
    self.treeview.append_column(self.columns["ond"])
....

所以,我个人希望,如果我点击出现在列条目中的复选框将是“可切换的”,但事实并非如此。这是因为我的操作系统(Mac OS X 10.8),还是我忘记设置某种属性?

4

1 回答 1

1

您必须绑定一个回调函数,该函数可能会反转 GtkListStore/GtkTreeStore 中的值以toggled发出信号。像这样:

 def on_cellrenderertoggle_toggled(self, cellrenderertoggle, path):
    # self.liststore is the tree modal of that treeview
    self.liststore[path][1] = not self.liststore[path][1]

完整的教程可以在这里找到:http: //python-gtk-3-tutorial.readthedocs.org/en/latest/cellrenderers.html#cellrenderertoggle

于 2013-06-26T02:27:18.917 回答