GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Tue Sep 30, 2014 1:51 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: pygtk can't render GtkBox
PostPosted: Fri Nov 04, 2011 9:00 pm 
Offline
GTK+ Geek

Joined: Mon Jan 05, 2009 9:37 am
Posts: 68
Location: Austria
Hi All,

I believe, it must be some trivial problem, but I can't find the solution. It appears that in glade 3.10, the developers have done away with GtkVBox, and GtkHBox, and there is only a GktBox, in which one can set the orientation to either vertical, or horizontal. The problem is that pygtk doesn't seem to know about this change, and it fails with the error message
Code:
v923z@penguin:gui$ python test.py
test.py:17: Warning: cannot create instance of abstract (non-instantiatable) type `GtkBox'
  self.builder.add_from_file('test.glade')
Segmentation fault

If I replace all occurrences of GtkBox to GtkHBox, everything works fine. Here is my test code
Code:
#!/usr/bin/python

import pygtk
import gtk
import gtk.glade
import gtk.keysyms

class test:
   def __init__(self):
      self.builder = gtk.Builder()
      self.builder.add_from_file('test.glade')
      self.window = self.widget('window1')
      self.builder.connect_signals(self)
      
   def widget(self, name):
      return self.builder.get_object(name)

   pass

if __name__=='__main__':
   app = test()
   app.window.show()
   gtk.main()

Is there something else that I should do to make pygtk realise the new situation?
Cheers,
Zoltán


Top
 Profile  
 
 Post subject: Re: pygtk can't render GtkBox
PostPosted: Sat Nov 05, 2011 5:02 pm 
Offline
Never Seen the Sunlight

Joined: Wed Jul 23, 2008 10:31 am
Posts: 2406
Location: Slovenia
Hello.

IIRC, Glade-3.8 is the last series supporting GTK+-2.x, while Glade-3.10 is meant to be used by GTK+-3.x applications (that means using gobject-introspection based python bindings in your case). So the preferred solution here would be to install glade-3.8, but on small projects like yours, simply running sed over the XML would also be an option.

Cheers,
Tadej


Top
 Profile  
 
 Post subject: Re: pygtk can't render GtkBox
PostPosted: Sat Nov 05, 2011 9:39 pm 
Offline
GTK+ Geek

Joined: Mon Jan 05, 2009 9:37 am
Posts: 68
Location: Austria
Greetings Tadej,
tadeboro wrote:
IIRC, Glade-3.8 is the last series supporting GTK+-2.x, while Glade-3.10 is meant to be used by GTK+-3.x applications

You are right. I should have looked at the header of the glade file more carefully. It clearly states that the interface requires gtk+3.0.
tadeboro wrote:
So the preferred solution here would be to install glade-3.8, but on small projects like yours, simply running sed over the XML would also be an option.

The difficulty with sed is that it is a bit awkward to process multiple lines. The GtkVBox looks like this
Code:
      <object class="GtkBox" id="box1">
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <property name="orientation">vertical</property>

i.e., one learns only in the fourth line that we have a vertical box. But all the same, it won't be hard to hack something to process the file.
Cheers,
Zoltán

EDIT: It seems that glade creates the proper hbox and vbox, if one adds it to the gui by right-clicking on it, and chooses "Add parent -> Horizontal box". Perhaps, this option remained in the code by accident...


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google Adsense [Bot] and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group