{"id":323,"date":"2008-10-22T15:47:16","date_gmt":"2008-10-22T21:47:16","guid":{"rendered":"http:\/\/blog.the-erm.com\/?p=323"},"modified":"2008-10-22T15:47:16","modified_gmt":"2008-10-22T21:47:16","slug":"treeview-and-the-frustration","status":"publish","type":"post","link":"https:\/\/blog.the-erm.com\/?p=323","title":{"rendered":"TreeView and the frustration"},"content":{"rendered":"<p>Anyone that&#8217;s ever used treeview, might understand my frustration.<\/p>\n<p>I really don&#8217;t understand the reasoning behind forcing people to use cellrenders.<\/p>\n<p><!--more--><\/p>\n<p>There are so many other ways to handle this, if I had the knowledge, this is how I&#8217;d do it.<\/p>\n<p>Cells would be widgets,<br \/>\n<code><br \/>\nclass myWidget(gtk.Label):<br \/>\ndef __init__(self,text=None):<br \/>\ngtk.Label.__init__(self,text)<\/p>\n<p>def set_value(self,text):<br \/>\nself.set_text(text)<\/code><\/p>\n<p>You&#8217;d create subclasses, and use them, but noooooo we&#8217;re stuck using cellrenders that have no easy way to add a widget to.\u00c2\u00a0 You&#8217;re stuck looking up gtk.style to &#8220;draw&#8221; things.<\/p>\n<p>I don&#8217;t know but it just seems like a lot of extra steps that aren&#8217;t needed to render cells, there&#8217;s a lot of reasearch that goes into using a treeview, when subclasses could have been used.<\/p>\n<p>Your main treeview would still use a liststore, but when it was time to update all it&#8217;d have to do is call obj.set_value(foo) while it was looping.\u00c2\u00a0 I really have no clue how all this stuff works, I just know how I&#8217;d do it if I were setting up the language.<\/p>\n<p>With gtk you use pack_start() pack_end() and add() to add widgets to various other widgets like a vbox, hbox, notebooks etc.<\/p>\n<p>pack_start is used for treeviews, but it has to be a subclass of a cellrenderer, and thus makes it extreamealy difficult to add things.\u00c2\u00a0 There are a few cellrenders for a comobox, entry, images, etc.\u00c2\u00a0 However what happens when you want to implement a custom widget &#8230; it&#8217;s damm near impossible without a month to a week of reasearch.<\/p>\n<p>The reason being if you wanted to set up a complicated widget you could &#8230;.<\/p>\n<p><code><br \/>\nclass MyComplexWidget(gtk.EventBox):<br \/>\ndef __init__(self):<br \/>\ngtk.EventBox.__init__(self)<br \/>\nvbox = gtk.VBox()<br \/>\nself.value = 0<br \/>\nself.pack_start(vbox)<br \/>\nself.label = gtk.Label(str(self.value))<br \/>\nself.connect('scroll-event',self.scroll)<\/p>\n<p>def set_value(self,value):<br \/>\nself.value = value<\/p>\n<p>def scroll(self,*args):<br \/>\nself.value = self.value + 1<br \/>\nself.label = gtk.Label(str(self.value))<br \/>\nself.emit('scroll-event',*args)<\/code><\/p>\n<p>treeviewCol.pack_start(myComplexWidget)<\/p>\n<p>Maybe it&#8217;s just me &#8230; maybe I&#8217;m an idiot, maybe the cellrenderer is exactly this, the problem is I&#8217;ve seen nill for simply adding a pre-existing widget on the web.\u00c2\u00a0 You have to draw *everything*<\/p>\n<p>Enough of complaining, maybe someone out there will know what I&#8217;m talking about, and an easy way to set it up, or you&#8217;ll totally agree with what I&#8217;m saying.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Anyone that&#8217;s ever used treeview, might understand my frustration. I really don&#8217;t understand the reasoning behind forcing people to use cellrenders.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[81,83,79],"tags":[117,118,116],"class_list":["post-323","post","type-post","status-publish","format-standard","hentry","category-gtk","category-pygtk","category-python","tag-gtk","tag-pygtk","tag-python"],"_links":{"self":[{"href":"https:\/\/blog.the-erm.com\/index.php?rest_route=\/wp\/v2\/posts\/323","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.the-erm.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.the-erm.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.the-erm.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.the-erm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=323"}],"version-history":[{"count":1,"href":"https:\/\/blog.the-erm.com\/index.php?rest_route=\/wp\/v2\/posts\/323\/revisions"}],"predecessor-version":[{"id":325,"href":"https:\/\/blog.the-erm.com\/index.php?rest_route=\/wp\/v2\/posts\/323\/revisions\/325"}],"wp:attachment":[{"href":"https:\/\/blog.the-erm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=323"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.the-erm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=323"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.the-erm.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=323"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}