如何将此代码从 Gtk 3 更改为 pygtk 2.0?
https://github.com/sebp/PyGObject-Tutorial/blob/master/examples/cellrenderertoggle_example.py
我有这部分。
#!/usr/bin/env python
import pygtk
pygtk.require('2.0')
import gtk
class CellRendererToggle:
def cell_toggled(self, widget, path):
self.liststore[path][1] = not self.liststore[path][1]
def __init__(self):
window = gtk.Window()
window.set_default_size(200, 200)
self.liststore = gtk.ListStore(str, bool, bool)
self.liststore.append(["Debian", False, False])
self.liststore.append(["OpenSuse", False, False])
self.liststore.append(["Fedora", False, False])
treeview = gtk.TreeView(model=self.liststore)
cellrenderer_text = gtk.CellRendererText()
column_text = gtk.TreeViewColumn("Text", cellrenderer_text, text=0)
treeview.append_column(column_text)
cellrenderer_toggle = gtk.CellRendererToggle()
cellrenderer_toggle.connect("toggled", self.cell_toggled)
column_toggle = gtk.TreeViewColumn("Toggle", cellrenderer_toggle, active=1)
treeview.append_column(column_toggle)
renderer_radio = gtk.CellRendererToggle()
renderer_radio.set_radio(True)
renderer_radio.connect("toggled", self.cell_radio_toggled)
column_radio = gtk.TreeViewColumn("Radio", renderer_radio, active=2)
treeview.append_column(column_radio)
window.connect("destroy", lambda w: gtk.main_quit())
window.add(treeview)
window.show_all()
CellRendererToggle()
gtk.main()