我有一个最简单的 TreeView 示例,大部分是从basictreeview.py复制的,但更简单,但 TreeView 本身不会显示在顶层窗口内。怎么了:
import gtk
class Application(object):
def __init__(self):
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.set_title("Alignment Editor")
self.window.set_default_size(1024, 768)
self.window.connect("delete_event", lambda w,e: gtk.main_quit())
self.row = ["a", "b", "c", "d", "e", "f", "g", "h"]
self.store = gtk.ListStore(*[str]*len(self.row)) #create len(word) columns
self.store.append(self.row)
self.treeview = gtk.TreeView(self.store)
self.treeview.set_reorderable(True)
self.window.add(self.treeview)
self.window.show_all()
if __name__ == "__main__":
Application()
gtk.main()