Problem with GtkBuilder

View: New views
5 Messages — Rating Filter:   Alert me  

Problem with GtkBuilder

by Aidin Gharibnavaz-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi!

I have a problem with glade, and GtkBuilder. I create a UI with glade, and load
it in my python application, using following codes:

   builder = gtk.Builder();
   builder.add_from_file("sample.glade")
  
It works nicely. But I can't add something to my containers using 'pack_start()',
'add_child()', or anything else. I do as following:

   builder.get_object('vbox1').add_child(mywidget)

 It don't throw any error, but also don't add 'mywidget' into the box.
 Is it possible to do something like this?
 The reason is that I have a custom widget, and I want to add it to my UI
 using code. (I couldn't add it to Glade's catalog. Glade's Doc didn't help)
 
 Thanks in advanced.


_______________________________________________
Glade-users maillist  -  Glade-users@...
http://lists.ximian.com/mailman/listinfo/glade-users

Re: Problem with GtkBuilder

by M3nt0r3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Aidin Gharibnavaz wrote:

Hi!

I have a problem with glade, and GtkBuilder. I create a UI with glade, and load
it in my python application, using following codes:

   builder = gtk.Builder();
   builder.add_from_file("sample.glade")
  
It works nicely. But I can't add something to my containers using 'pack_start()',
'add_child()', or anything else. I do as following:

   builder.get_object('vbox1').add_child(mywidget)

 It don't throw any error, but also don't add 'mywidget' into the box.
 Is it possible to do something like this?
 The reason is that I have a custom widget, and I want to add it to my UI
 using code. (I couldn't add it to Glade's catalog. Glade's Doc didn't help)
 
 Thanks in advanced.


_______________________________________________ Glade-users maillist - Glade-users@... http://lists.ximian.com/mailman/listinfo/glade-users
i wrote a simple howto to make a catalogs and pythonplugins

http://forum.promotux.it/viewtopic.php?f=32&t=79

It is in italian for now, i ll try to translate with my bad english.

I just migrate an ERP to gtkBuilder and i had some problems with custom widgets and adding elements to "box".
My experience tells that the problem is because gtkbuilder doesntt use "root" part in the builder so if you have a table inside a widget you can't take the table and add it to another part.  I "deparent" the table splitting parts in the same glade file and it works well.

I' ll waiting for PyObject in liststore build column to migrate also generic treeviews.

regard

F.

_______________________________________________
Glade-users maillist  -  Glade-users@...
http://lists.ximian.com/mailman/listinfo/glade-users

Re: Problem with GtkBuilder

by Alexey Kurochkin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, 2009-10-07 at 14:41 +0330, Aidin Gharibnavaz wrote:

> Hi!
>
> I have a problem with glade, and GtkBuilder. I create a UI with glade,
> and load
> it in my python application, using following codes:
>
>    builder = gtk.Builder();
>    builder.add_from_file("sample.glade")
>    
> It works nicely. But I can't add something to my containers using
> 'pack_start()',
> 'add_child()', or anything else. I do as following:
>
>    builder.get_object('vbox1').add_child(mywidget)
>
>  It don't throw any error, but also don't add 'mywidget' into the box.

Are you sure "add_child" is the right method? I don't know much of
python, but guessing from my C experience for boxes it should be
something like "pack_start".

>  Is it possible to do something like this?
>  The reason is that I have a custom widget, and I want to add it to my
> UI
>  using code. (I couldn't add it to Glade's catalog. Glade's Doc didn't
> help)
>  
>  Thanks in advanced.
>
> _______________________________________________
> Glade-users maillist  -  Glade-users@...
> http://lists.ximian.com/mailman/listinfo/glade-users


_______________________________________________
Glade-users maillist  -  Glade-users@...
http://lists.ximian.com/mailman/listinfo/glade-users

Re: Problem with GtkBuilder

by Tristan Van Berkom-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, Oct 7, 2009 at 10:37 AM, Alexey Kurochkin
<alexey.kurochkin@...> wrote:

> On Wed, 2009-10-07 at 14:41 +0330, Aidin Gharibnavaz wrote:
>> Hi!
>>
>> I have a problem with glade, and GtkBuilder. I create a UI with glade,
>> and load
>> it in my python application, using following codes:
>>
>>    builder = gtk.Builder();
>>    builder.add_from_file("sample.glade")
>>
>> It works nicely. But I can't add something to my containers using
>> 'pack_start()',
>> 'add_child()', or anything else. I do as following:
>>
>>    builder.get_object('vbox1').add_child(mywidget)
>>
>>  It don't throw any error, but also don't add 'mywidget' into the box.

Hmm, is it possible that the toplevel 'vbox1' in your project that you are
trying to parent is set to be visible=false ? ... just a guess... it would be
a classic case of seems to not work...

Cheers,
           -Tristan
_______________________________________________
Glade-users maillist  -  Glade-users@...
http://lists.ximian.com/mailman/listinfo/glade-users

Re: Problem with GtkBuilder

by Manuel Alejandro Cerón Estrada-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2009/10/7 Aidin Gharibnavaz <aidin@...>:

> Hi!
>
> I have a problem with glade, and GtkBuilder. I create a UI with glade, and
> load
> it in my python application, using following codes:
>
>    builder = gtk.Builder();
>    builder.add_from_file("sample.glade")
>
> It works nicely. But I can't add something to my containers using
> 'pack_start()',
> 'add_child()', or anything else. I do as following:
>
>    builder.get_object('vbox1').add_child(mywidget)
>
>  It don't throw any error, but also don't add 'mywidget' into the box.
>  Is it possible to do something like this?

Yes, it is possible. With boxes the methods pack_start and pack_end
are preferred. Remember you should show the widget after add it to the
box:

builder.get_object('vbox1').pack_start(mywidget)
mywidget.show()

If your widget is composed of multiple sub widgets, you should use:

mywidget.show_all()

>  The reason is that I have a custom widget, and I want to add it to my UI
>  using code. (I couldn't add it to Glade's catalog. Glade's Doc didn't help)
>
>  Thanks in advanced.
>
> _______________________________________________
> Glade-users maillist  -  Glade-users@...
> http://lists.ximian.com/mailman/listinfo/glade-users
>
>
_______________________________________________
Glade-users maillist  -  Glade-users@...
http://lists.ximian.com/mailman/listinfo/glade-users