我在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),还是有某种我忘记设置的属性?
答案 0 :(得分: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