Blob Blame History Raw
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Python Gtk widgets support: Glade User Interface Designer Reference Manual</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="index.html" title="Glade User Interface Designer Reference Manual">
<link rel="up" href="catalog.html" title="Part I. Adding your custom widgets">
<link rel="prev" href="properties.html" title="Property Class Definitions">
<link rel="next" href="core.html" title="Part II. Glade Core">
<meta name="generator" content="GTK-Doc V1.28 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle">
<td width="100%" align="left" class="shortcuts"></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
<td><a accesskey="u" href="catalog.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td>
<td><a accesskey="p" href="properties.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
<td><a accesskey="n" href="core.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
</tr></table>
<div class="refentry">
<a name="pythonsupport"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle">Python Gtk widgets support</span></h2>
<p>Add python support to your catalog — 
How to write and install a catalog for a python widget library
   </p>
</td>
<td class="gallery_image" valign="top" align="right"></td>
</tr></table></div>
<div class="refsect1">
<a name="id-1.2.5.3"></a><h2>Introduction</h2>
<p>
Glade supports loading widgets coded in python by linking and running the python
interpreter from the gladepython catalog plugin.
   </p>
<p>
So in order for glade to include your python gtk widgets you will have to:

<dt></dt><dd>
a) specify gladepython support code as your plugin library.
</dd>

<dt></dt><dd>
b) set glade_python_init as you init function.
</dd>

<dt></dt><dd>
c) make sure your catalog name is the same as your python import library since
<code class="function">glade_python_init()</code> will use this name to import your widgets into the
interpreter.
</dd>

     </p>
<pre class="programlisting">

&lt;glade-catalog name="pythonplugin" library="gladepython"
domain="glade-3" depends="gtk+"&gt;
 &lt;init-function&gt;glade_python_init&lt;/init-function&gt;

 &lt;glade-widget-classes&gt;
   &lt;glade-widget-class title="MyBox" name="MyBox" generic-name="mybox"/&gt;
 &lt;/glade-widget-classes&gt;

 &lt;glade-widget-group name="python" title="Python"&gt;
   &lt;glade-widget-class-ref name="MyBox"/&gt;
 &lt;/glade-widget-group&gt;
&lt;/glade-catalog&gt;
     </pre>
<p>
   </p>
<p>
Glade's python interpreter will look up for your widgets in the same
places it looks
for regular catalogs plugins, that is $GLADE_ENV_MODULE_PATH
enviroment variable
and `pkg-config --variable=moduledir gladeui-2.0`

So the easiest thing would be to make a symlink in one of those directory, just
do not forget that the name should be the one specified in your catalog name.
   </p>
<p>
pythonplugin.py
     </p>
<pre class="programlisting">

from gi.repository import Gtk

class MyBox(Gtk.HBox):
       __gtype_name__ = 'MyBox'

       def __init__(self):
               Gtk.HBox.__init__(self)

     </pre>
<p>
   </p>
</div>
</div>
<div class="footer">
<hr>Generated by GTK-Doc V1.28</div>
</body>
</html>