[pygtk] Using TreeView in PyGTK

Zoltán Vörös zvoros at gmail.com
Tue Dec 13 03:52:06 WST 2011


Why don't you check out this example? 
http://zetcode.com/tutorials/pygtktutorial/advancedwidgets/
I hope this helps,
Zoltán

On 12/12/2011 07:39 PM, ben at b3ns.com wrote:
> Hi,
>
> I am figuring out the basics of PyGTK, and I am trying to get a 
> ListView so I can display a list of usernames. I don't think I am 
> doing it right and nothing is displayed when executing the PyGTK 
> application. The code is below - thanks:
>
> import gtk
> import gobject
>
> class PyGTKApp:
>         button = gtk.Button("Click Here!")
>         hBox = gtk.HBox()
>     hBox2 = gtk.HBox()
>         vBox = gtk.VBox()
>         def __init__(self):
>                 self.window = gtk.Window()
>         self.treeView = gtk.TreeView()
>         self.listStore = gtk.ListStore(gobject.TYPE_STRING)
>         self.cellRenderer = gtk.CellRendererText()
>         self.treeViewColumn = gtk.TreeViewColumn("Users", 
> self.cellRenderer, text=0)
>         self.appendC = 
> self.treeViewColumn.add_attribute(self.cellRenderer, "Bammurdo", 1)
>                 self.window.set_title("PyGTK Application")
>                 self.window.connect("destroy", gtk.main_quit)
>                 self.window.set_size_request(400,100)
>                 self.window.add(self.vBox)
>                 self.vBox.pack_start(self.hBox,0)
>         self.vBox.pack_start(self.hBox2,0)
>                 self.hBox.pack_start(gtk.HBox(),1,0)
>                 self.hBox.pack_start(self.button,0,0)
>                 self.hBox.pack_start(gtk.HBox(),1,0)
>         self.hBox2.pack_start(gtk.HBox(),1,0)
>         self.hBox2.pack_start(self.treeView)
>         self.hBox2.pack_start(gtk.HBox(),1,0)
>                 self.window.show_all()
> PyGTKApp()
> gtk.main()
>
> Best Regards.
> _______________________________________________
> pygtk mailing list   pygtk at daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://faq.pygtk.org/
>


More information about the pygtk mailing list