[Glade-users] adding custom widgets

Gerald Britton gerald.britton at gmail.com
Tue Apr 21 16:18:49 EDT 2009


I found a better resource:

http://www.pygtk.org/articles/custom-widgets-glade/Custom_PyGTK_Widgets_in_Glade3-part-2.html

At least it makes more sense to me than the first one.  I followed the
instructions, saved my catalog and module like the ones there, then
fired up Glade-3.

I set the environment variables:

$ env |grep -i GLA
GLADE_MODULE_PATH=/home/jerryb1/modules
GLADE_CATALOG_PATH=/home/jerryb1/catalogs

Here's the catalog

$ cat catalogs/grampswidgets.xml
<?xml version="1.0" encoding="UTF-8"?>
<glade-catalog name="grampswidgets" library="grampswidgets"
                            domain="glade-3" depends="gtk+" language="python">
  <glade-widget-classes>
    <glade-widget-class
        name="LatitudeLongitude"
        title="Latitude Longitude"
        generic-name="lat_long"/>
    <glade-widget-class
        name="DateEntry"
        title="Date Entry"
        generic-name="date_entry"/>
  </glade-widget-classes>
  <glade-widget-group name="GrampsWidgets" title="Gramps Widgets">
    <glade-widget-class-ref name="LatitudeLongitude"/>
    <glade-widget-class-ref name="DateEntry"/>
  </glade-widget-group>
</glade-catalog>

Here's the module:

$ cat modules/grampswidgets.py
from date_entry import DateEntry

But at startup I get:

(glade-3:20805): GladeUI-CRITICAL **: Unable to load module
'grampswidgets' from any search paths

(glade-3:20805): GladeUI-WARNING **: Failed to load external library
'grampswidgets'


I also copied the module name without the ".py" but it made no
difference.  So, where is it looking for the module?

On Tue, Apr 21, 2009 at 3:37 PM, Gerald Britton
<gerald.britton at gmail.com> wrote:
> OK -- I found I needed an additional package (libgladeui-1-dev)
>
> Now I'm trying to set up a catalog.  The difficulty for me at this
> point is that I want to use it with Python.  Following the docs, and
> another tutorial I found,
>
> http://unpythonic.blogspot.com/2007/03/custom-pygtk-widgets-in-glade3.html
>
> I built a catalog, adding language="python" to the glade-catalog
> element.  But, I can't see how the Python code for the module would
> work, knowing what I do about Python imports.
>
> I'd sure love to see an end-to-end example.  Starting with vanilla
> glade-3, add a catalog and custom widgets, build a glade file using
> glade-3 using the custom widgets then see what the gtk+ application
> code looks like -- all with Python as the implementation language.
>
> On Tue, Apr 21, 2009 at 2:49 PM, Tristan Van Berkom
> <tristan.van.berkom at gmail.com> wrote:
>> On Tue, Apr 21, 2009 at 2:00 PM, Gerald Britton
>> <gerald.britton at gmail.com> wrote:
>>> I'm just reading through:
>>>
>>> http://glade.gnome.org/docs/catalog.html
>>>
>>> After reading the three pages under this heading and trying a few
>>> things out, its obvious to me that I have no idea what I'm doing.  My
>>> goal is to be able to design and use custom widgets using Glade-3 for
>>> my gtk-builder applications.  So, I thought I just play the dummy and
>>> do what is in the documentation by rote to see what happened.  I got
>>> to the part about "Validating and installing" and hit some snags right
>>> away:
>>>
>>> The command:
>>>
>>>    xmllint --dtdvalid glade-catalog.dtd --noout my-catalog.xml
>>>
>>> failed because I can't find glade-catalog.dtd on my system.  Any idea
>>> where to get it or what package it might be in?
>>
>> Its in the tarball, but current versions are out of date for the catalog DTD
>> (I've actually never used it...) but someone has written a patch against
>> the current DTD here http://bugzilla.gnome.org/show_bug.cgi?id=578465,
>> which just needs a little work since it defines an ordering of tag which
>> is not mandatory (with an updated DTD, I'll introduce it to our Makefiles
>> so that our catalogs get validated at build time).
>>
>> If you are creating custom virtual properties by way of the catalog
>> (i.e. in the case you may be faking a class purely by catalog without
>> loading the actual widget type into Glade), then please look at
>> plugins/gtk+/gtk+.xml.in for better examples, we have better support
>> for that now but I havent yet brought the docs up to date in that respect.
>>
>>>
>>> The command:
>>>
>>>    pkg-config --variable=catalogdir gladeui-1.0
>>>
>>> just exits without printing any directory.  Guess I'm missing
>>> something here as well. Same thing with the other pkg-config commands.
>>
>> Do you have Glade headers and pc files installed ? if you built from sources;
>> where did you install Glade ? if you installed Glade in /opt for instance,
>> you will need to set PKG_CONFIG_PATH=/opt/lib/pkgconfig:/usr/lib/pkgconfig
>>
>> Alternatively you can just set GLADE_CATALOG_PATH=~/catalogs when
>> firing up Glade and it should pickup any catalogs you put in ~/catalogs
>>
>> Cheers,
>>         -Tristan
>>
>
>
>
> --
> Gerald Britton
>



-- 
Gerald Britton


More information about the Glade-users mailing list