summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Pablo Ugarte <juanpablougarte@gmail.com>2020-06-05 20:17:14 -0300
committerJuan Pablo Ugarte <juanpablougarte@gmail.com>2020-06-05 20:17:14 -0300
commitb973d72ed9ca31471cda0147768b2487fee2672c (patch)
treec08b3afe8495dfb65d8f06d05410c2ae75954baf
parent6f4fb5672f41201a20e0f879a7d7d7b96f045425 (diff)
downloadglade-b973d72ed9ca31471cda0147768b2487fee2672c.tar.gz
Docs: update python catalog example
Update examples to show how to set properties defined in python at runtime.
-rw-r--r--doc/gladepython.sgml26
1 files changed, 19 insertions, 7 deletions
diff --git a/doc/gladepython.sgml b/doc/gladepython.sgml
index 141f6a4e..d8b00a15 100644
--- a/doc/gladepython.sgml
+++ b/doc/gladepython.sgml
@@ -34,6 +34,7 @@ glade_python_init() will use this name to import your widgets into the
interpreter.
</listitem></varlistentry>
+pythonplugin.xml
<programlisting>
<![CDATA[
<glade-catalog name="pythonplugin" library="gladepython"
@@ -41,11 +42,11 @@ domain="glade-3" depends="gtk+">
<init-function>glade_python_init</init-function>
<glade-widget-classes>
- <glade-widget-class title="MyBox" name="MyBox" generic-name="mybox"/>
+ <glade-widget-class title="MyPythonBox" name="MyPythonBox" generic-name="mypythonbox"/>
</glade-widget-classes>
<glade-widget-group name="python" title="Python">
- <glade-widget-class-ref name="MyBox"/>
+ <glade-widget-class-ref name="MyPythonBox"/>
</glade-widget-group>
</glade-catalog>]]>
</programlisting>
@@ -66,13 +67,24 @@ do not forget that the name should be the one specified in your catalog name.
pythonplugin.py
<programlisting>
<![CDATA[
-from gi.repository import Gtk
+from gi.repository import GLib, Gtk, GObject
-class MyBox(Gtk.HBox):
- __gtype_name__ = 'MyBox'
+class MyPythonBox(Gtk.Box):
+ __gtype_name__ = 'MyPythonBox'
- def __init__(self):
- Gtk.HBox.__init__(self)
+ foo = GObject.Property(type=int, nick='An integer')
+ bar = GObject.Property(type=str, nick='A String')
+
+ def _update(self, obj, pspec):
+ self.label.set_text ('Python Properties\nInteger = ' + str(self.foo) + '\nString = \'' + self.bar + '\'')
+
+ def __init__ (self):
+ Gtk.Box.__init__ (self)
+ self.label = Gtk.Label (visible = True)
+ self.add (self.label)
+ self.connect('notify::foo', self._update)
+ self.connect('notify::bar', self._update)
+ self._update(None, None)
]]>
</programlisting>
</para>