Blob Blame History Raw
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<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">
<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>
<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
<td class="gallery_image" valign="top" align="right"></td>
<div class="refsect1">
<a name="id-"></a><h2>Introduction</h2>
Glade supports loading widgets coded in python by linking and running the python
interpreter from the gladepython catalog plugin.
So in order for glade to include your python gtk widgets you will have to:

a) specify gladepython support code as your plugin library.

b) set glade_python_init as you init function.

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

<pre class="programlisting">

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

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

 &lt;glade-widget-group name="python" title="Python"&gt;
   &lt;glade-widget-class-ref name="MyBox"/&gt;
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.
<pre class="programlisting">

from gi.repository import Gtk

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

       def __init__(self):

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