summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorJames Henstridge <jamesh@src.gnome.org>1998-12-06 10:08:08 +0000
committerJames Henstridge <jamesh@src.gnome.org>1998-12-06 10:08:08 +0000
commit997c302f261c2000d057bdaa989ec12ca00d7fa9 (patch)
tree32fd0d0cf70a0d804df0765d610518db281801a0 /examples
downloadpygtk-997c302f261c2000d057bdaa989ec12ca00d7fa9.tar.gz
Initial revision
Diffstat (limited to 'examples')
-rw-r--r--examples/glade/.cvsignore6
-rw-r--r--examples/glade/README12
-rwxr-xr-xexamples/glade/glade.py27
-rw-r--r--examples/glade/test.glade499
-rw-r--r--examples/glade/test2.glade89
-rw-r--r--examples/glade/tmp1692
-rw-r--r--examples/ide/.cvsignore6
-rw-r--r--examples/ide/README7
-rw-r--r--examples/ide/break.xpm29
-rwxr-xr-xexamples/ide/browse.py117
-rw-r--r--examples/ide/continue.xpm27
-rw-r--r--examples/ide/edit.py181
-rw-r--r--examples/ide/edit.xpm38
-rwxr-xr-xexamples/ide/gtkcons.py329
-rwxr-xr-xexamples/ide/gtkdb.py350
-rwxr-xr-xexamples/ide/gtkprof.py133
-rw-r--r--examples/ide/minibreak.xpm19
-rw-r--r--examples/ide/next.xpm32
-rwxr-xr-xexamples/ide/pyide.py180
-rw-r--r--examples/ide/quit.xpm36
-rw-r--r--examples/ide/return.xpm35
-rw-r--r--examples/ide/run.xpm28
-rw-r--r--examples/ide/step.xpm35
-rw-r--r--examples/imlib/.cvsignore6
-rwxr-xr-xexamples/imlib/view.py52
-rw-r--r--examples/neil/.cvsignore6
-rw-r--r--examples/neil/README4
-rwxr-xr-xexamples/neil/TAppli.py142
-rwxr-xr-xexamples/neil/TAppli2.py129
-rwxr-xr-xexamples/neil/TAppli3.py141
-rwxr-xr-xexamples/neil/TAppli4.py126
-rwxr-xr-xexamples/neil/TAppli5.py188
-rw-r--r--examples/neil/bomb.xpm47
-rw-r--r--examples/neil/gtk-logo.xpm162
-rwxr-xr-xexamples/neil/notebook.py63
-rw-r--r--examples/neil/question.xpm42
-rw-r--r--examples/simple/.cvsignore6
-rw-r--r--examples/simple/README5
-rw-r--r--examples/simple/dnd.py77
-rwxr-xr-xexamples/simple/hello1.py32
-rwxr-xr-xexamples/simple/hello2.py29
-rwxr-xr-xexamples/simple/scribble.py81
-rwxr-xr-xexamples/simple/simple1.py37
-rwxr-xr-xexamples/simple/simple2.py26
-rwxr-xr-xexamples/simple/tooltip1.py43
-rwxr-xr-xexamples/simple/tooltip2.py32
-rw-r--r--examples/testgtk/.cvsignore6
-rw-r--r--examples/testgtk/README4
-rw-r--r--examples/testgtk/test.xpm92
-rwxr-xr-xexamples/testgtk/testgtk.py1525
-rw-r--r--examples/testgtk/testgtkrc69
51 files changed, 7079 insertions, 0 deletions
diff --git a/examples/glade/.cvsignore b/examples/glade/.cvsignore
new file mode 100644
index 00000000..c2831020
--- /dev/null
+++ b/examples/glade/.cvsignore
@@ -0,0 +1,6 @@
+Makefile.in
+Makefile
+*~
+*.pyc
+*.pyo
+
diff --git a/examples/glade/README b/examples/glade/README
new file mode 100644
index 00000000..d83c582d
--- /dev/null
+++ b/examples/glade/README
@@ -0,0 +1,12 @@
+This directory contains examples of the use of the pyglade module, which can
+be used for creating user interfaces from the .glade files created by the
+GLADE UI builder.
+
+Just put a glade file in this directory and run:
+ ./glade.py filename.glade
+
+The pyglade module should make it even easier to prototype interfaces in
+python, since you can get it to look right, and act correctly when signals
+get emitted, then generate a C skeleton for the UI.
+
+You can find GLADE at http://www.comp.lancs.ac.uk/~damon/builder/index.html \ No newline at end of file
diff --git a/examples/glade/glade.py b/examples/glade/glade.py
new file mode 100755
index 00000000..a7778783
--- /dev/null
+++ b/examples/glade/glade.py
@@ -0,0 +1,27 @@
+#!/usr/bin/env python
+import sys
+if sys.version[:3] == '1.4':
+ import ni
+from gtk import *
+import pyglade
+
+if len(sys.argv) > 1:
+ fname = sys.argv[1]
+else:
+ fname = 'test.glade'
+
+# create widget tree ...
+wtree = pyglade.construct(fname)
+
+# if there is anything that needs to be added to the UI, we can access all
+# the widgets like this:
+try:
+ win = wtree.get_widget('window1')
+except: pass
+
+# we can connect to any of the signals named in the template:
+try:
+ wtree.connect('close_window', mainquit)
+except: pass
+
+mainloop()
diff --git a/examples/glade/test.glade b/examples/glade/test.glade
new file mode 100644
index 00000000..85d288f8
--- /dev/null
+++ b/examples/glade/test.glade
@@ -0,0 +1,499 @@
+<?xml version="1.0"?>
+<GTK-Interface>
+
+
+<widget>
+ <class>GtkWindow</class>
+ <name>window1</name>
+ <Signal>
+ <name>destroy</name>
+ <handler>close_window</handler>
+ </Signal>
+ <title>window1</title>
+ <type>GTK_WINDOW_TOPLEVEL</type>
+ <position>GTK_WIN_POS_NONE</position>
+ <allow_shrink>True</allow_shrink>
+ <allow_grow>True</allow_grow>
+ <auto_shrink>False</auto_shrink>
+
+ <widget>
+ <class>GtkTable</class>
+ <name>table1</name>
+ <border_width>2</border_width>
+ <rows>5</rows>
+ <columns>3</columns>
+ <homogeneous>False</homogeneous>
+ <row_spacing>2</row_spacing>
+ <column_spacing>2</column_spacing>
+
+ <widget>
+ <class>GtkLabel</class>
+ <name>label1</name>
+ <child>
+ <left_attach>0</left_attach>
+ <right_attach>1</right_attach>
+ <top_attach>1</top_attach>
+ <bottom_attach>2</bottom_attach>
+ <xpad>0</xpad>
+ <ypad>0</ypad>
+ <xexpand>True</xexpand>
+ <yexpand>True</yexpand>
+ <xshrink>False</xshrink>
+ <yshrink>False</yshrink>
+ <xfill>True</xfill>
+ <yfill>True</yfill>
+ </child>
+ <label>Hello</label>
+ <justify>GTK_JUSTIFY_CENTER</justify>
+ <xalign>0.5</xalign>
+ <yalign>0.5</yalign>
+ <xpad>0</xpad>
+ <ypad>0</ypad>
+ </widget>
+
+ <widget>
+ <class>GtkEntry</class>
+ <name>entry1</name>
+ <child>
+ <left_attach>1</left_attach>
+ <right_attach>2</right_attach>
+ <top_attach>1</top_attach>
+ <bottom_attach>2</bottom_attach>
+ <xpad>0</xpad>
+ <ypad>0</ypad>
+ <xexpand>True</xexpand>
+ <yexpand>True</yexpand>
+ <xshrink>False</xshrink>
+ <yshrink>False</yshrink>
+ <xfill>True</xfill>
+ <yfill>True</yfill>
+ </child>
+ <width>50</width>
+ <can_focus>True</can_focus>
+ <editable>True</editable>
+ <text_visible>True</text_visible>
+ <text_max_length>0</text_max_length>
+ <text></text>
+ </widget>
+
+ <widget>
+ <class>GtkArrow</class>
+ <name>arrow1</name>
+ <child>
+ <left_attach>2</left_attach>
+ <right_attach>3</right_attach>
+ <top_attach>1</top_attach>
+ <bottom_attach>2</bottom_attach>
+ <xpad>0</xpad>
+ <ypad>0</ypad>
+ <xexpand>True</xexpand>
+ <yexpand>True</yexpand>
+ <xshrink>False</xshrink>
+ <yshrink>False</yshrink>
+ <xfill>True</xfill>
+ <yfill>True</yfill>
+ </child>
+ <arrow_type>GTK_ARROW_LEFT</arrow_type>
+ <shadow_type>GTK_SHADOW_OUT</shadow_type>
+ <xalign>0.5</xalign>
+ <yalign>0.5</yalign>
+ <xpad>0</xpad>
+ <ypad>0</ypad>
+ </widget>
+
+ <widget>
+ <class>GtkSpinButton</class>
+ <name>spinbutton1</name>
+ <child>
+ <left_attach>0</left_attach>
+ <right_attach>1</right_attach>
+ <top_attach>2</top_attach>
+ <bottom_attach>3</bottom_attach>
+ <xpad>0</xpad>
+ <ypad>0</ypad>
+ <xexpand>True</xexpand>
+ <yexpand>True</yexpand>
+ <xshrink>False</xshrink>
+ <yshrink>False</yshrink>
+ <xfill>True</xfill>
+ <yfill>True</yfill>
+ </child>
+ <can_focus>True</can_focus>
+ <climb_rate>1</climb_rate>
+ <digits>0</digits>
+ <numeric>False</numeric>
+ <update_policy>GTK_UPDATE_IF_VALID</update_policy>
+ <snap>False</snap>
+ <wrap>False</wrap>
+ <hvalue>1</hvalue>
+ <hlower>0</hlower>
+ <hupper>100</hupper>
+ <hstep>1</hstep>
+ <hpage>10</hpage>
+ <hpage_size>10</hpage_size>
+ </widget>
+
+ <widget>
+ <class>GtkHScale</class>
+ <name>hscale1</name>
+ <child>
+ <left_attach>1</left_attach>
+ <right_attach>2</right_attach>
+ <top_attach>2</top_attach>
+ <bottom_attach>3</bottom_attach>
+ <xpad>0</xpad>
+ <ypad>0</ypad>
+ <xexpand>True</xexpand>
+ <yexpand>True</yexpand>
+ <xshrink>False</xshrink>
+ <yshrink>False</yshrink>
+ <xfill>True</xfill>
+ <yfill>True</yfill>
+ </child>
+ <width>75</width>
+ <can_focus>True</can_focus>
+ <draw_value>True</draw_value>
+ <value_pos>GTK_POS_TOP</value_pos>
+ <digits>1</digits>
+ <policy>GTK_UPDATE_CONTINUOUS</policy>
+ <hvalue>0</hvalue>
+ <hlower>0</hlower>
+ <hupper>100</hupper>
+ <hstep>1</hstep>
+ <hpage>10</hpage>
+ <hpage_size>10</hpage_size>
+ </widget>
+
+ <widget>
+ <class>GtkFixed</class>
+ <name>fixed1</name>
+ <child>
+ <left_attach>2</left_attach>
+ <right_attach>3</right_attach>
+ <top_attach>2</top_attach>
+ <bottom_attach>3</bottom_attach>
+ <xpad>0</xpad>
+ <ypad>0</ypad>
+ <xexpand>True</xexpand>
+ <yexpand>True</yexpand>
+ <xshrink>False</xshrink>
+ <yshrink>False</yshrink>
+ <xfill>True</xfill>
+ <yfill>True</yfill>
+ </child>
+
+ <widget>
+ <class>GtkButton</class>
+ <name>button1</name>
+ <x>40</x>
+ <y>40</y>
+ <width>47</width>
+ <height>22</height>
+ <can_focus>True</can_focus>
+ <label>button1</label>
+ </widget>
+
+ <widget>
+ <class>GtkSpinButton</class>
+ <name>spinbutton2</name>
+ <x>16</x>
+ <y>0</y>
+ <width>45</width>
+ <height>22</height>
+ <can_focus>True</can_focus>
+ <climb_rate>1</climb_rate>
+ <digits>0</digits>
+ <numeric>False</numeric>
+ <update_policy>GTK_UPDATE_ALWAYS</update_policy>
+ <snap>False</snap>
+ <wrap>False</wrap>
+ <hvalue>1</hvalue>
+ <hlower>0</hlower>
+ <hupper>100</hupper>
+ <hstep>1</hstep>
+ <hpage>10</hpage>
+ <hpage_size>10</hpage_size>
+ </widget>
+ </widget>
+
+ <widget>
+ <class>GtkFrame</class>
+ <name>frame1</name>
+ <child>
+ <left_attach>0</left_attach>
+ <right_attach>3</right_attach>
+ <top_attach>3</top_attach>
+ <bottom_attach>4</bottom_attach>
+ <xpad>0</xpad>
+ <ypad>0</ypad>
+ <xexpand>True</xexpand>
+ <yexpand>True</yexpand>
+ <xshrink>False</xshrink>
+ <yshrink>False</yshrink>
+ <xfill>True</xfill>
+ <yfill>True</yfill>
+ </child>
+ <label_xalign>0</label_xalign>
+ <shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
+
+ <widget>
+ <class>GtkHButtonBox</class>
+ <name>hbuttonbox1</name>
+ <layout_style>GTK_BUTTONBOX_DEFAULT_STYLE</layout_style>
+ <spacing>30</spacing>
+ <child_min_width>85</child_min_width>
+ <child_min_height>27</child_min_height>
+ <child_ipad_x>7</child_ipad_x>
+ <child_ipad_y>0</child_ipad_y>
+
+ <widget>
+ <class>GtkButton</class>
+ <name>button2</name>
+ <can_focus>True</can_focus>
+ <label>button2</label>
+ </widget>
+
+ <widget>
+ <class>GtkButton</class>
+ <name>button3</name>
+ <can_focus>True</can_focus>
+ <label>button3</label>
+ </widget>
+
+ <widget>
+ <class>GtkButton</class>
+ <name>button4</name>
+ <can_focus>True</can_focus>
+ <label>button4</label>
+ </widget>
+ </widget>
+ </widget>
+
+ <widget>
+ <class>GtkAlignment</class>
+ <name>alignment1</name>
+ <child>
+ <left_attach>1</left_attach>
+ <right_attach>2</right_attach>
+ <top_attach>4</top_attach>
+ <bottom_attach>5</bottom_attach>
+ <xpad>0</xpad>
+ <ypad>0</ypad>
+ <xexpand>True</xexpand>
+ <yexpand>True</yexpand>
+ <xshrink>False</xshrink>
+ <yshrink>False</yshrink>
+ <xfill>True</xfill>
+ <yfill>True</yfill>
+ </child>
+ <xalign>0.5</xalign>
+ <yalign>0.5</yalign>
+ <xscale>1</xscale>
+ <yscale>1</yscale>
+
+ <widget>
+ <class>GtkVScrollbar</class>
+ <name>vscrollbar1</name>
+ <can_focus>True</can_focus>
+ <policy>GTK_UPDATE_CONTINUOUS</policy>
+ <vvalue>0</vvalue>
+ <vlower>0</vlower>
+ <vupper>0</vupper>
+ <vstep>0</vstep>
+ <vpage>0</vpage>
+ <vpage_size>0</vpage_size>
+ </widget>
+ </widget>
+
+ <widget>
+ <class>GtkAlignment</class>
+ <name>alignment2</name>
+ <child>
+ <left_attach>0</left_attach>
+ <right_attach>1</right_attach>
+ <top_attach>4</top_attach>
+ <bottom_attach>5</bottom_attach>
+ <xpad>0</xpad>
+ <ypad>0</ypad>
+ <xexpand>True</xexpand>
+ <yexpand>True</yexpand>
+ <xshrink>False</xshrink>
+ <yshrink>False</yshrink>
+ <xfill>True</xfill>
+ <yfill>True</yfill>
+ </child>
+ <xalign>0.5</xalign>
+ <yalign>0.5</yalign>
+ <xscale>1</xscale>
+ <yscale>1</yscale>
+
+ <widget>
+ <class>GtkCurve</class>
+ <name>curve1</name>
+ <curve_type>GTK_CURVE_TYPE_SPLINE</curve_type>
+ <min_x>0</min_x>
+ <max_x>1</max_x>
+ <min_y>0</min_y>
+ <max_y>1</max_y>
+ </widget>
+ </widget>
+
+ <widget>
+ <class>GtkCList</class>
+ <name>clist1</name>
+ <child>
+ <left_attach>2</left_attach>
+ <right_attach>3</right_attach>
+ <top_attach>4</top_attach>
+ <bottom_attach>5</bottom_attach>
+ <xpad>0</xpad>
+ <ypad>0</ypad>
+ <xexpand>True</xexpand>
+ <yexpand>True</yexpand>
+ <xshrink>False</xshrink>
+ <yshrink>False</yshrink>
+ <xfill>True</xfill>
+ <yfill>True</yfill>
+ </child>
+ <can_focus>True</can_focus>
+ <columns>3</columns>
+ <column_widths>80,80,80</column_widths>
+ <selection_mode>GTK_SELECTION_SINGLE</selection_mode>
+ <show_titles>True</show_titles>
+ <shadow_type>GTK_SHADOW_IN</shadow_type>
+ <hscrollbar_policy>GTK_POLICY_AUTOMATIC</hscrollbar_policy>
+ <vscrollbar_policy>GTK_POLICY_AUTOMATIC</vscrollbar_policy>
+
+ <widget>
+ <class>GtkLabel</class>
+ <child_name>CList:title</child_name>
+ <name>label2</name>
+ <label>Col1</label>
+ <justify>GTK_JUSTIFY_CENTER</justify>
+ <xalign>0.5</xalign>
+ <yalign>0.5</yalign>
+ <xpad>0</xpad>
+ <ypad>0</ypad>
+ </widget>
+
+ <widget>
+ <class>GtkLabel</class>
+ <child_name>CList:title</child_name>
+ <name>label3</name>
+ <label>Col3</label>
+ <justify>GTK_JUSTIFY_CENTER</justify>
+ <xalign>0.5</xalign>
+ <yalign>0.5</yalign>
+ <xpad>0</xpad>
+ <ypad>0</ypad>
+ </widget>
+
+ <widget>
+ <class>GtkArrow</class>
+ <child_name>CList:title</child_name>
+ <name>arrow2</name>
+ <arrow_type>GTK_ARROW_DOWN</arrow_type>
+ <shadow_type>GTK_SHADOW_OUT</shadow_type>
+ <xalign>0.5</xalign>
+ <yalign>0.5</yalign>
+ <xpad>0</xpad>
+ <ypad>0</ypad>
+ </widget>
+ </widget>
+
+ <widget>
+ <class>GtkNotebook</class>
+ <name>notebook1</name>
+ <child>
+ <left_attach>0</left_attach>
+ <right_attach>3</right_attach>
+ <top_attach>0</top_attach>
+ <bottom_attach>1</bottom_attach>
+ <xpad>0</xpad>
+ <ypad>0</ypad>
+ <xexpand>True</xexpand>
+ <yexpand>True</yexpand>
+ <xshrink>False</xshrink>
+ <yshrink>False</yshrink>
+ <xfill>True</xfill>
+ <yfill>True</yfill>
+ </child>
+ <can_focus>True</can_focus>
+ <show_tabs>True</show_tabs>
+ <show_border>True</show_border>
+ <tab_pos>GTK_POS_TOP</tab_pos>
+ <scrollable>False</scrollable>
+ <tab_border>3</tab_border>
+ <popup_enable>False</popup_enable>
+
+ <widget>
+ <class>GtkHRuler</class>
+ <name>hruler1</name>
+ <metric>GTK_PIXELS</metric>
+ <lower>0</lower>
+ <upper>10</upper>
+ <position>0</position>
+ <max_size>10</max_size>
+ </widget>
+
+ <widget>
+ <class>GtkHScale</class>
+ <name>hscale2</name>
+ <can_focus>True</can_focus>
+ <draw_value>True</draw_value>
+ <value_pos>GTK_POS_TOP</value_pos>
+ <digits>1</digits>
+ <policy>GTK_UPDATE_CONTINUOUS</policy>
+ <hvalue>0</hvalue>
+ <hlower>0</hlower>
+ <hupper>100</hupper>
+ <hstep>1</hstep>
+ <hpage>10</hpage>
+ <hpage_size>10</hpage_size>
+ </widget>
+
+ <widget>
+ <class>GtkProgressBar</class>
+ <name>progressbar1</name>
+ </widget>
+
+ <widget>
+ <class>GtkLabel</class>
+ <child_name>Notebook:tab</child_name>
+ <name>label5</name>
+ <label>label5</label>
+ <justify>GTK_JUSTIFY_CENTER</justify>
+ <xalign>0.5</xalign>
+ <yalign>0.5</yalign>
+ <xpad>0</xpad>
+ <ypad>0</ypad>
+ </widget>
+
+ <widget>
+ <class>GtkLabel</class>
+ <child_name>Notebook:tab</child_name>
+ <name>label6</name>
+ <label>label6</label>
+ <justify>GTK_JUSTIFY_CENTER</justify>
+ <xalign>0.5</xalign>
+ <yalign>0.5</yalign>
+ <xpad>0</xpad>
+ <ypad>0</ypad>
+ </widget>
+
+ <widget>
+ <class>GtkLabel</class>
+ <child_name>Notebook:tab</child_name>
+ <name>label7</name>
+ <label>label7</label>
+ <justify>GTK_JUSTIFY_CENTER</justify>
+ <xalign>0.5</xalign>
+ <yalign>0.5</yalign>
+ <xpad>0</xpad>
+ <ypad>0</ypad>
+ </widget>
+ </widget>
+ </widget>
+</widget>
+
+</GTK-Interface>
diff --git a/examples/glade/test2.glade b/examples/glade/test2.glade
new file mode 100644
index 00000000..d128d2cf
--- /dev/null
+++ b/examples/glade/test2.glade
@@ -0,0 +1,89 @@
+<?xml version="1.0"?>
+<GTK-Interface>
+
+<style>
+ <style_name>Hello</style_name>
+ <style_font>-adobe-helvetica-bold-r-normal-*-*-180-*-*-p-*-iso8859-1</style_font>
+ <fg:NORMAL>0,0,255</fg:NORMAL>
+</style>
+
+<widget>
+ <class>GtkWindow</class>
+ <name>window1</name>
+ <Signal>
+ <name>destroy</name>
+ <handler>close_window</handler>
+ </Signal>
+ <title>window1</title>
+ <type>GTK_WINDOW_TOPLEVEL</type>
+ <position>GTK_WIN_POS_NONE</position>
+ <allow_shrink>True</allow_shrink>
+ <allow_grow>True</allow_grow>
+ <auto_shrink>False</auto_shrink>
+
+ <widget>
+ <class>GtkVBox</class>
+ <name>vbox1</name>
+ <homogeneous>False</homogeneous>
+ <spacing>0</spacing>
+
+ <widget>
+ <class>GtkCombo</class>
+ <name>combo1</name>
+ <border_width>5</border_width>
+ <child>
+ <padding>0</padding>
+ <expand>False</expand>
+ <fill>True</fill>
+ </child>
+ <Signal>
+ <name>add</name>
+ <handler>on_combo1_add</handler>
+ <object>window1</object>
+ </Signal>
+ <case_sensitive>False</case_sensitive>
+ <use_arrows>True</use_arrows>
+ <use_arrows_always>False</use_arrows_always>
+ </widget>
+
+ <widget>
+ <class>GtkHRuler</class>
+ <name>hruler1</name>
+ <child>
+ <padding>0</padding>
+ <expand>False</expand>
+ <fill>True</fill>
+ </child>
+ <height>32</height>
+ <style_name>Hello</style_name>
+ <Accelerator>
+ <modifiers>GDK_CONTROL_MASK</modifiers>
+ <key>GDK_0</key>
+ <signal>hide</signal>
+ </Accelerator>
+ <Accelerator>
+ <modifiers>GDK_CONTROL_MASK</modifiers>
+ <key>GDK_1</key>
+ <signal>show</signal>
+ </Accelerator>
+ <metric>GTK_PIXELS</metric>
+ <lower>0</lower>
+ <upper>10</upper>
+ <position>0</position>
+ <max_size>10</max_size>
+ </widget>
+
+ <widget>
+ <class>GtkStatusbar</class>
+ <name>statusbar1</name>
+ <border_width>10</border_width>
+ <child>
+ <padding>0</padding>
+ <expand>True</expand>
+ <fill>True</fill>
+ </child>
+ </widget>
+ </widget>
+</widget>
+
+</GTK-Interface>
diff --git a/examples/glade/tmp b/examples/glade/tmp
new file mode 100644
index 00000000..c45f34d7
--- /dev/null
+++ b/examples/glade/tmp
@@ -0,0 +1,1692 @@
+xml: encoding = None standalone = None
+data: '\012'
+start tag: <GTK-Interface>
+data: '\012\012\012'
+start tag: <widget>
+data: '\012 '
+start tag: <class>
+data: 'GtkWindow'
+end tag: </class>
+data: '\012 '
+start tag: <name>
+data: 'window1'
+end tag: </name>
+data: '\012 '
+start tag: <Signal>
+data: '\012 '
+start tag: <name>
+data: 'destroy'
+end tag: </name>
+data: '\012 '
+start tag: <handler>
+data: 'close_window'
+end tag: </handler>
+data: '\012 '
+end tag: </Signal>
+data: '\012 '
+start tag: <title>
+data: 'window1'
+end tag: </title>
+data: '\012 '
+start tag: <type>
+data: 'GTK_WINDOW_TOPLEVEL'
+end tag: </type>
+data: '\012 '
+start tag: <position>
+data: 'GTK_WIN_POS_NONE'
+end tag: </position>
+data: '\012 '
+start tag: <allow_shrink>
+data: 'True'
+end tag: </allow_shrink>
+data: '\012 '
+start tag: <allow_grow>
+data: 'True'
+end tag: </allow_grow>
+data: '\012 '
+start tag: <auto_shrink>
+data: 'False'
+end tag: </auto_shrink>
+data: '\012\012 '
+start tag: <widget>
+data: '\012 '
+start tag: <class>
+data: 'GtkTable'
+end tag: </class>
+data: '\012 '
+start tag: <name>
+data: 'table1'
+end tag: </name>
+data: '\012 '
+start tag: <border_width>
+data: '2'
+end tag: </border_width>
+data: '\012 '
+start tag: <rows>
+data: '5'
+end tag: </rows>
+data: '\012 '
+start tag: <columns>
+data: '3'
+end tag: </columns>
+data: '\012 '
+start tag: <homogeneous>
+data: 'False'
+end tag: </homogeneous>
+data: '\012 '
+start tag: <row_spacing>
+data: '2'
+end tag: </row_spacing>
+data: '\012 '
+start tag: <column_spacing>
+data: '2'
+end tag: </column_spacing>
+data: '\012\012 '
+start tag: <widget>
+data: '\012 '
+start tag: <class>
+data: 'GtkLabel'
+end tag: </class>
+data: '\012 '
+start tag: <name>
+data: 'label1'
+end tag: </name>
+data: '\012 '
+start tag: <child>
+data: '\012 '
+start tag: <left_attach>
+data: '0'
+end tag: </left_attach>
+data: '\012 '
+start tag: <right_attach>
+data: '1'
+end tag: </right_attach>
+data: '\012 '
+start tag: <top_attach>
+data: '1'
+end tag: </top_attach>
+data: '\012 '
+start tag: <bottom_attach>
+data: '2'
+end tag: </bottom_attach>
+data: '\012 '
+start tag: <xpad>
+data: '0'
+end tag: </xpad>
+data: '\012 '
+start tag: <ypad>
+data: '0'
+end tag: </ypad>
+data: '\012 '
+start tag: <xexpand>
+data: 'True'
+end tag: </xexpand>
+data: '\012 '
+start tag: <yexpand>
+data: 'True'
+end tag: </yexpand>
+data: '\012 '
+start tag: <xshrink>
+data: 'False'
+end tag: </xshrink>
+data: '\012 '
+start tag: <yshrink>
+data: 'False'
+end tag: </yshrink>
+data: '\012 '
+start tag: <xfill>
+data: 'True'
+end tag: </xfill>
+data: '\012 '
+start tag: <yfill>
+data: 'True'
+end tag: </yfill>
+data: '\012 '
+end tag: </child>
+data: '\012 '
+start tag: <label>
+data: 'Hello'
+end tag: </label>
+data: '\012 '
+start tag: <justify>
+data: 'GTK_JUSTIFY_CENTER'
+end tag: </justify>
+data: '\012 '
+start tag: <xalign>
+data: '0.5'
+end tag: </xalign>
+data: '\012 '
+start tag: <yalign>
+data: '0.5'
+end tag: </yalign>
+data: '\012 '
+start tag: <xpad>
+data: '0'
+end tag: </xpad>
+data: '\012 '
+start tag: <ypad>
+data: '0'
+end tag: </ypad>
+data: '\012 '
+end tag: </widget>
+data: '\012\012 '
+start tag: <widget>
+data: '\012 '
+start tag: <class>
+data: 'GtkEntry'
+end tag: </class>
+data: '\012 '
+start tag: <name>
+data: 'entry1'
+end tag: </name>
+data: '\012 '
+start tag: <child>
+data: '\012 '
+start tag: <left_attach>
+data: '1'
+end tag: </left_attach>
+data: '\012 '
+start tag: <right_attach>
+data: '2'
+end tag: </right_attach>
+data: '\012 '
+start tag: <top_attach>
+data: '1'
+end tag: </top_attach>
+data: '\012 '
+start tag: <bottom_attach>
+data: '2'
+end tag: </bottom_attach>
+data: '\012 '
+start tag: <xpad>
+data: '0'
+end tag: </xpad>
+data: '\012 '
+start tag: <ypad>
+data: '0'
+end tag: </ypad>
+data: '\012 '
+start tag: <xexpand>
+data: 'True'
+end tag: </xexpand>
+data: '\012 '
+start tag: <yexpand>
+data: 'True'
+end tag: </yexpand>
+data: '\012 '
+start tag: <xshrink>
+data: 'False'
+end tag: </xshrink>
+data: '\012 '
+start tag: <yshrink>
+data: 'False'
+end tag: </yshrink>
+data: '\012 '
+start tag: <xfill>
+data: 'True'
+end tag: </xfill>
+data: '\012 '
+start tag: <yfill>
+data: 'True'
+end tag: </yfill>
+data: '\012 '
+end tag: </child>
+data: '\012 '
+start tag: <width>
+data: '50'
+end tag: </width>
+data: '\012 '
+start tag: <can_focus>
+data: 'True'
+end tag: </can_focus>
+data: '\012 '
+start tag: <editable>
+data: 'True'
+end tag: </editable>
+data: '\012 '
+start tag: <text_visible>
+data: 'True'
+end tag: </text_visible>
+data: '\012 '
+start tag: <text_max_length>
+data: '0'
+end tag: </text_max_length>
+data: '\012 '
+start tag: <text>
+end tag: </text>
+data: '\012 '
+end tag: </widget>
+data: '\012\012 '
+start tag: <widget>
+data: '\012 '
+start tag: <class>
+data: 'GtkArrow'
+end tag: </class>
+data: '\012 '
+start tag: <name>
+data: 'arrow1'
+end tag: </name>
+data: '\012 '
+start tag: <child>
+data: '\012 '
+start tag: <left_attach>
+data: '2'
+end tag: </left_attach>
+data: '\012 '
+start tag: <right_attach>
+data: '3'
+end tag: </right_attach>
+data: '\012 '
+start tag: <top_attach>
+data: '1'
+end tag: </top_attach>
+data: '\012 '
+start tag: <bottom_attach>
+data: '2'
+end tag: </bottom_attach>
+data: '\012 '
+start tag: <xpad>
+data: '0'
+end tag: </xpad>
+data: '\012 '
+start tag: <ypad>
+data: '0'
+end tag: </ypad>
+data: '\012 '
+start tag: <xexpand>
+data: 'True'
+end tag: </xexpand>
+data: '\012 '
+start tag: <yexpand>
+data: 'True'
+end tag: </yexpand>
+data: '\012 '
+start tag: <xshrink>
+data: 'False'
+end tag: </xshrink>
+data: '\012 '
+start tag: <yshrink>
+data: 'False'
+end tag: </yshrink>
+data: '\012 '
+start tag: <xfill>
+data: 'True'
+end tag: </xfill>
+data: '\012 '
+start tag: <yfill>
+data: 'True'
+end tag: </yfill>
+data: '\012 '
+end tag: </child>
+data: '\012 '
+start tag: <arrow_type>
+data: 'GTK_ARROW_LEFT'
+end tag: </arrow_type>
+data: '\012 '
+start tag: <shadow_type>
+data: 'GTK_SHADOW_OUT'
+end tag: </shadow_type>
+data: '\012 '
+start tag: <xalign>
+data: '0.5'
+end tag: </xalign>
+data: '\012 '
+start tag: <yalign>
+data: '0.5'
+end tag: </yalign>
+data: '\012 '
+start tag: <xpad>
+data: '0'
+end tag: </xpad>
+data: '\012 '
+start tag: <ypad>
+data: '0'
+end tag: </ypad>
+data: '\012 '
+end tag: </widget>
+data: '\012\012 '
+start tag: <widget>
+data: '\012 '
+start tag: <class>
+data: 'GtkSpinButton'
+end tag: </class>
+data: '\012 '
+start tag: <name>
+data: 'spinbutton1'
+end tag: </name>
+data: '\012 '
+start tag: <child>
+data: '\012 '
+start tag: <left_attach>
+data: '0'
+end tag: </left_attach>
+data: '\012 '
+start tag: <right_attach>
+data: '1'
+end tag: </right_attach>
+data: '\012 '
+start tag: <top_attach>
+data: '2'
+end tag: </top_attach>
+data: '\012 '
+start tag: <bottom_attach>
+data: '3'
+end tag: </bottom_attach>
+data: '\012 '
+start tag: <xpad>
+data: '0'
+end tag: </xpad>
+data: '\012 '
+start tag: <ypad>
+data: '0'
+end tag: </ypad>
+data: '\012 '
+start tag: <xexpand>
+data: 'True'
+end tag: </xexpand>
+data: '\012 '
+start tag: <yexpand>
+data: 'True'
+end tag: </yexpand>
+data: '\012 '
+start tag: <xshrink>
+data: 'False'
+end tag: </xshrink>
+data: '\012 '
+start tag: <yshrink>
+data: 'False'
+end tag: </yshrink>
+data: '\012 '
+start tag: <xfill>
+data: 'True'
+end tag: </xfill>
+data: '\012 '
+start tag: <yfill>
+data: 'True'
+end tag: </yfill>
+data: '\012 '
+end tag: </child>
+data: '\012 '
+start tag: <can_focus>
+data: 'True'
+end tag: </can_focus>
+data: '\012 '
+start tag: <climb_rate>
+data: '1'
+end tag: </climb_rate>
+data: '\012 '
+start tag: <digits>
+data: '0'
+end tag: </digits>
+data: '\012 '
+start tag: <numeric>
+data: 'False'
+end tag: </numeric>
+data: '\012 '
+start tag: <update_policy>
+data: 'GTK_UPDATE_IF_VALID'
+end tag: </update_policy>
+data: '\012 '
+start tag: <snap>
+data: 'False'
+end tag: </snap>
+data: '\012 '
+start tag: <wrap>
+data: 'False'
+end tag: </wrap>
+data: '\012 '
+start tag: <hvalue>
+data: '1'
+end tag: </hvalue>
+data: '\012 '
+start tag: <hlower>
+data: '0'
+end tag: </hlower>
+data: '\012 '
+start tag: <hupper>
+data: '100'
+end tag: </hupper>
+data: '\012 '
+start tag: <hstep>
+data: '1'
+end tag: </hstep>
+data: '\012 '
+start tag: <hpage>
+data: '10'
+end tag: </hpage>
+data: '\012 '
+start tag: <hpage_size>
+data: '10'
+end tag: </hpage_size>
+data: '\012 '
+end tag: </widget>
+data: '\012\012 '
+start tag: <widget>
+data: '\012 '
+start tag: <class>
+data: 'GtkHScale'
+end tag: </class>
+data: '\012 '
+start tag: <name>
+data: 'hscale1'
+end tag: </name>
+data: '\012 '
+start tag: <child>
+data: '\012 '
+start tag: <left_attach>
+data: '1'
+end tag: </left_attach>
+data: '\012 '
+start tag: <right_attach>
+data: '2'
+end tag: </right_attach>
+data: '\012 '
+start tag: <top_attach>
+data: '2'
+end tag: </top_attach>
+data: '\012 '
+start tag: <bottom_attach>
+data: '3'
+end tag: </bottom_attach>
+data: '\012 '
+start tag: <xpad>
+data: '0'
+end tag: </xpad>
+data: '\012 '
+start tag: <ypad>
+data: '0'
+end tag: </ypad>
+data: '\012 '
+start tag: <xexpand>
+data: 'True'
+end tag: </xexpand>
+data: '\012 '
+start tag: <yexpand>
+data: 'True'
+end tag: </yexpand>
+data: '\012 '
+start tag: <xshrink>
+data: 'False'
+end tag: </xshrink>
+data: '\012 '
+start tag: <yshrink>
+data: 'False'
+end tag: </yshrink>
+data: '\012 '
+start tag: <xfill>
+data: 'True'
+end tag: </xfill>
+data: '\012 '
+start tag: <yfill>
+data: 'True'
+end tag: </yfill>
+data: '\012 '
+end tag: </child>
+data: '\012 '
+start tag: <width>
+data: '75'
+end tag: </width>
+data: '\012 '
+start tag: <can_focus>
+data: 'True'
+end tag: </can_focus>
+data: '\012 '
+start tag: <draw_value>
+data: 'True'
+end tag: </draw_value>
+data: '\012 '
+start tag: <value_pos>
+data: 'GTK_POS_TOP'
+end tag: </value_pos>
+data: '\012 '
+start tag: <digits>
+data: '1'
+end tag: </digits>
+data: '\012 '
+start tag: <policy>
+data: 'GTK_UPDATE_CONTINUOUS'
+end tag: </policy>
+data: '\012 '
+start tag: <hvalue>
+data: '0'
+end tag: </hvalue>
+data: '\012 '
+start tag: <hlower>
+data: '0'
+end tag: </hlower>
+data: '\012 '
+start tag: <hupper>
+data: '100'
+end tag: </hupper>
+data: '\012 '
+start tag: <hstep>
+data: '1'
+end tag: </hstep>
+data: '\012 '
+start tag: <hpage>
+data: '10'
+end tag: </hpage>
+data: '\012 '
+start tag: <hpage_size>
+data: '10'
+end tag: </hpage_size>
+data: '\012 '
+end tag: </widget>
+data: '\012\012 '
+start tag: <widget>
+data: '\012 '
+start tag: <class>
+data: 'GtkFixed'
+end tag: </class>
+data: '\012 '
+start tag: <name>
+data: 'fixed1'
+end tag: </name>
+data: '\012 '
+start tag: <child>
+data: '\012 '
+start tag: <left_attach>
+data: '2'
+end tag: </left_attach>
+data: '\012 '
+start tag: <right_attach>
+data: '3'
+end tag: </right_attach>
+data: '\012 '
+start tag: <top_attach>
+data: '2'
+end tag: </top_attach>
+data: '\012 '
+start tag: <bottom_attach>
+data: '3'
+end tag: </bottom_attach>
+data: '\012 '
+start tag: <xpad>
+data: '0'
+end tag: </xpad>
+data: '\012 '
+start tag: <ypad>
+data: '0'
+end tag: </ypad>
+data: '\012 '
+start tag: <xexpand>
+data: 'True'
+end tag: </xexpand>
+data: '\012 '
+start tag: <yexpand>
+data: 'True'
+end tag: </yexpand>
+data: '\012 '
+start tag: <xshrink>
+data: 'False'
+end tag: </xshrink>
+data: '\012 '
+start tag: <yshrink>
+data: 'False'
+end tag: </yshrink>
+data: '\012 '
+start tag: <xfill>
+data: 'True'
+end tag: </xfill>
+data: '\012 '
+start tag: <yfill>
+data: 'True'
+end tag: </yfill>
+data: '\012 '
+end tag: </child>
+data: '\012\012 '
+start tag: <widget>
+data: '\012 '
+start tag: <class>
+data: 'GtkButton'
+end tag: </class>
+data: '\012 '
+start tag: <name>
+data: 'button1'
+end tag: </name>
+data: '\012 '
+start tag: <x>
+data: '40'
+end tag: </x>
+data: '\012 '
+start tag: <y>
+data: '40'
+end tag: </y>
+data: '\012 '
+start tag: <width>
+data: '47'
+end tag: </width>
+data: '\012 '
+start tag: <height>
+data: '22'
+end tag: </height>
+data: '\012 '
+start tag: <can_focus>
+data: 'True'
+end tag: </can_focus>
+data: '\012 '
+start tag: <label>
+data: 'button1'
+end tag: </label>
+data: '\012 '
+end tag: </widget>
+data: '\012\012 '
+start tag: <widget>
+data: '\012 '
+start tag: <class>
+data: 'GtkSpinButton'
+end tag: </class>
+data: '\012 '
+start tag: <name>
+data: 'spinbutton2'
+end tag: </name>
+data: '\012 '
+start tag: <x>
+data: '16'
+end tag: </x>
+data: '\012 '
+start tag: <y>
+data: '0'
+end tag: </y>
+data: '\012 '
+start tag: <width>
+data: '45'
+end tag: </width>
+data: '\012 '
+start tag: <height>
+data: '22'
+end tag: </height>
+data: '\012 '
+start tag: <can_focus>
+data: 'True'
+end tag: </can_focus>
+data: '\012 '
+start tag: <climb_rate>
+data: '1'
+end tag: </climb_rate>
+data: '\012 '
+start tag: <digits>
+data: '0'
+end tag: </digits>
+data: '\012 '
+start tag: <numeric>
+data: 'False'
+end tag: </numeric>
+data: '\012 '
+start tag: <update_policy>
+data: 'GTK_UPDATE_ALWAYS'
+end tag: </update_policy>
+data: '\012 '
+start tag: <snap>
+data: 'False'
+end tag: </snap>
+data: '\012 '
+start tag: <wrap>
+data: 'False'
+end tag: </wrap>
+data: '\012 '
+start tag: <hvalue>
+data: '1'
+end tag: </hvalue>
+data: '\012 '
+start tag: <hlower>
+data: '0'
+end tag: </hlower>
+data: '\012 '
+start tag: <hupper>
+data: '100'
+end tag: </hupper>
+data: '\012 '
+start tag: <hstep>
+data: '1'
+end tag: </hstep>
+data: '\012 '
+start tag: <hpage>
+data: '10'
+end tag: </hpage>
+data: '\012 '
+start tag: <hpage_size>
+data: '10'
+end tag: </hpage_size>
+data: '\012 '
+end tag: </widget>
+data: '\012 '
+end tag: </widget>
+data: '\012\012 '
+start tag: <widget>
+data: '\012 '
+start tag: <class>
+data: 'GtkFrame'
+end tag: </class>
+data: '\012 '
+start tag: <name>
+data: 'frame1'
+end tag: </name>
+data: '\012 '
+start tag: <child>
+data: '\012 '
+start tag: <left_attach>
+data: '0'
+end tag: </left_attach>
+data: '\012 '
+start tag: <right_attach>
+data: '3'
+end tag: </right_attach>
+data: '\012 '
+start tag: <top_attach>
+data: '3'
+end tag: </top_attach>
+data: '\012 '
+start tag: <bottom_attach>
+data: '4'
+end tag: </bottom_attach>
+data: '\012 '
+start tag: <xpad>
+data: '0'
+end tag: </xpad>
+data: '\012 '
+start tag: <ypad>
+data: '0'
+end tag: </ypad>
+data: '\012 '
+start tag: <xexpand>
+data: 'True'
+end tag: </xexpand>
+data: '\012 '
+start tag: <yexpand>
+data: 'True'
+end tag: </yexpand>
+data: '\012 '
+start tag: <xshrink>
+data: 'False'
+end tag: </xshrink>
+data: '\012 '
+start tag: <yshrink>
+data: 'False'
+end tag: </yshrink>
+data: '\012 '
+start tag: <xfill>
+data: 'True'
+end tag: </xfill>
+data: '\012 '
+start tag: <yfill>
+data: 'True'
+end tag: </yfill>
+data: '\012 '
+end tag: </child>
+data: '\012 '
+start tag: <label_xalign>
+data: '0'
+end tag: </label_xalign>
+data: '\012 '
+start tag: <shadow_type>
+data: 'GTK_SHADOW_ETCHED_IN'
+end tag: </shadow_type>
+data: '\012\012 '
+start tag: <widget>
+data: '\012 '
+start tag: <class>
+data: 'GtkHButtonBox'
+end tag: </class>
+data: '\012 '
+start tag: <name>
+data: 'hbuttonbox1'
+end tag: </name>
+data: '\012 '
+start tag: <layout_style>
+data: 'GTK_BUTTONBOX_DEFAULT_STYLE'
+end tag: </layout_style>
+data: '\012 '
+start tag: <spacing>
+data: '30'
+end tag: </spacing>
+data: '\012 '
+start tag: <child_min_width>
+data: '85'
+end tag: </child_min_width>
+data: '\012 '
+start tag: <child_min_height>
+data: '27'
+end tag: </child_min_height>
+data: '\012 '
+start tag: <child_ipad_x>
+data: '7'
+end tag: </child_ipad_x>
+data: '\012 '
+start tag: <child_ipad_y>
+data: '0'
+end tag: </child_ipad_y>
+data: '\012\012 '
+start tag: <widget>
+data: '\012 '
+start tag: <class>
+data: 'GtkButton'
+end tag: </class>
+data: '\012 '
+start tag: <name>
+data: 'button2'
+end tag: </name>
+data: '\012 '
+start tag: <can_focus>
+data: 'True'
+end tag: </can_focus>
+data: '\012 '
+start tag: <label>
+data: 'button2'
+end tag: </label>
+data: '\012 '
+end tag: </widget>
+data: '\012\012 '
+start tag: <widget>
+data: '\012 '
+start tag: <class>
+data: 'GtkButton'
+end tag: </class>
+data: '\012 '
+start tag: <name>
+data: 'button3'
+end tag: </name>
+data: '\012 '
+start tag: <can_focus>
+data: 'True'
+end tag: </can_focus>
+data: '\012 '
+start tag: <label>
+data: 'button3'
+end tag: </label>
+data: '\012 '
+end tag: </widget>
+data: '\012\012 '
+start tag: <widget>
+data: '\012 '
+start tag: <class>
+data: 'GtkButton'
+end tag: </class>
+data: '\012 '
+start tag: <name>
+data: 'button4'
+end tag: </name>
+data: '\012 '
+start tag: <can_focus>
+data: 'True'
+end tag: </can_focus>
+data: '\012 '
+start tag: <label>
+data: 'button4'
+end tag: </label>
+data: '\012 '
+end tag: </widget>
+data: '\012 '
+end tag: </widget>
+data: '\012 '
+end tag: </widget>
+data: '\012\012 '
+start tag: <widget>
+data: '\012 '
+start tag: <class>
+data: 'GtkAlignment'
+end tag: </class>
+data: '\012 '
+start tag: <name>
+data: 'alignment1'
+end tag: </name>
+data: '\012 '
+start tag: <child>
+data: '\012 '
+start tag: <left_attach>
+data: '1'
+end tag: </left_attach>
+data: '\012 '
+start tag: <right_attach>
+data: '2'
+end tag: </right_attach>
+data: '\012 '
+start tag: <top_attach>
+data: '4'
+end tag: </top_attach>
+data: '\012 '
+start tag: <bottom_attach>
+data: '5'
+end tag: </bottom_attach>
+data: '\012 '
+start tag: <xpad>
+data: '0'
+end tag: </xpad>
+data: '\012 '
+start tag: <ypad>
+data: '0'
+end tag: </ypad>
+data: '\012 '
+start tag: <xexpand>
+data: 'True'
+end tag: </xexpand>
+data: '\012 '
+start tag: <yexpand>
+data: 'True'
+end tag: </yexpand>
+data: '\012 '
+start tag: <xshrink>
+data: 'False'
+end tag: </xshrink>
+data: '\012 '
+start tag: <yshrink>
+data: 'False'
+end tag: </yshrink>
+data: '\012 '
+start tag: <xfill>
+data: 'True'
+end tag: </xfill>
+data: '\012 '
+start tag: <yfill>
+data: 'True'
+end tag: </yfill>
+data: '\012 '
+end tag: </child>
+data: '\012 '
+start tag: <xalign>
+data: '0.5'
+end tag: </xalign>
+data: '\012 '
+start tag: <yalign>
+data: '0.5'
+end tag: </yalign>
+data: '\012 '
+start tag: <xscale>
+data: '1'
+end tag: </xscale>
+data: '\012 '
+start tag: <yscale>
+data: '1'
+end tag: </yscale>
+data: '\012\012 '
+start tag: <widget>
+data: '\012 '
+start tag: <class>
+data: 'GtkVScrollbar'
+end tag: </class>
+data: '\012 '
+start tag: <name>
+data: 'vscrollbar1'
+end tag: </name>
+data: '\012 '
+start tag: <can_focus>
+data: 'True'
+end tag: </can_focus>
+data: '\012 '
+start tag: <policy>
+data: 'GTK_UPDATE_CONTINUOUS'
+end tag: </policy>
+data: '\012 '
+start tag: <vvalue>
+data: '0'
+end tag: </vvalue>
+data: '\012 '
+start tag: <vlower>
+data: '0'
+end tag: </vlower>
+data: '\012 '
+start tag: <vupper>
+data: '0'
+end tag: </vupper>
+data: '\012 '
+start tag: <vstep>
+data: '0'
+end tag: </vstep>
+data: '\012 '
+start tag: <vpage>
+data: '0'
+end tag: </vpage>
+data: '\012 '
+start tag: <vpage_size>
+data: '0'
+end tag: </vpage_size>
+data: '\012 '
+end tag: </widget>
+data: '\012 '
+end tag: </widget>
+data: '\012\012 '
+start tag: <widget>
+data: '\012 '
+start tag: <class>
+data: 'GtkAlignment'
+end tag: </class>
+data: '\012 '
+start tag: <name>
+data: 'alignment2'
+end tag: </name>
+data: '\012 '
+start tag: <child>
+data: '\012 '
+start tag: <left_attach>
+data: '0'
+end tag: </left_attach>
+data: '\012 '
+start tag: <right_attach>
+data: '1'
+end tag: </right_attach>
+data: '\012 '
+start tag: <top_attach>
+data: '4'
+end tag: </top_attach>
+data: '\012 '
+start tag: <bottom_attach>
+data: '5'
+end tag: </bottom_attach>
+data: '\012 '
+start tag: <xpad>
+data: '0'
+end tag: </xpad>
+data: '\012 '
+start tag: <ypad>
+data: '0'
+end tag: </ypad>
+data: '\012 '
+start tag: <xexpand>
+data: 'True'
+end tag: </xexpand>
+data: '\012 '
+start tag: <yexpand>
+data: 'True'
+end tag: </yexpand>
+data: '\012 '
+start tag: <xshrink>
+data: 'False'
+end tag: </xshrink>
+data: '\012 '
+start tag: <yshrink>
+data: 'False'
+end tag: </yshrink>
+data: '\012 '
+start tag: <xfill>
+data: 'True'
+end tag: </xfill>
+data: '\012 '
+start tag: <yfill>
+data: 'True'
+end tag: </yfill>
+data: '\012 '
+end tag: </child>
+data: '\012 '
+start tag: <xalign>
+data: '0.5'
+end tag: </xalign>
+data: '\012 '
+start tag: <yalign>
+data: '0.5'
+end tag: </yalign>
+data: '\012 '
+start tag: <xscale>
+data: '1'
+end tag: </xscale>
+data: '\012 '
+start tag: <yscale>
+data: '1'
+end tag: </yscale>
+data: '\012\012 '
+start tag: <widget>
+data: '\012 '
+start tag: <class>
+data: 'GtkCurve'
+end tag: </class>
+data: '\012 '
+start tag: <name>
+data: 'curve1'
+end tag: </name>
+data: '\012 '
+start tag: <curve_type>
+data: 'GTK_CURVE_TYPE_SPLINE'
+end tag: </curve_type>
+data: '\012 '
+start tag: <min_x>
+data: '0'
+end tag: </min_x>
+data: '\012 '
+start tag: <max_x>
+data: '1'
+end tag: </max_x>
+data: '\012 '
+start tag: <min_y>
+data: '0'
+end tag: </min_y>
+data: '\012 '
+start tag: <max_y>
+data: '1'
+end tag: </max_y>
+data: '\012 '
+end tag: </widget>
+data: '\012 '
+end tag: </widget>
+data: '\012\012 '
+start tag: <widget>
+data: '\012 '
+start tag: <class>
+data: 'GtkCList'
+end tag: </class>
+data: '\012 '
+start tag: <name>
+data: 'clist1'
+end tag: </name>
+data: '\012 '
+start tag: <child>
+data: '\012 '
+start tag: <left_attach>
+data: '2'
+end tag: </left_attach>
+data: '\012 '
+start tag: <right_attach>
+data: '3'
+end tag: </right_attach>
+data: '\012 '
+start tag: <top_attach>
+data: '4'
+end tag: </top_attach>
+data: '\012 '
+start tag: <bottom_attach>
+data: '5'
+end tag: </bottom_attach>
+data: '\012 '
+start tag: <xpad>
+data: '0'
+end tag: </xpad>
+data: '\012 '
+start tag: <ypad>
+data: '0'
+end tag: </ypad>
+data: '\012 '
+start tag: <xexpand>
+data: 'True'
+end tag: </xexpand>
+data: '\012 '
+start tag: <yexpand>
+data: 'True'
+end tag: </yexpand>
+data: '\012 '
+start tag: <xshrink>
+data: 'False'
+end tag: </xshrink>
+data: '\012 '
+start tag: <yshrink>
+data: 'False'
+end tag: </yshrink>
+data: '\012 '
+start tag: <xfill>
+data: 'True'
+end tag: </xfill>
+data: '\012 '
+start tag: <yfill>
+data: 'True'
+end tag: </yfill>
+data: '\012 '
+end tag: </child>
+data: '\012 '
+start tag: <can_focus>
+data: 'True'
+end tag: </can_focus>
+data: '\012 '
+start tag: <columns>
+data: '3'
+end tag: </columns>
+data: '\012 '
+start tag: <column_widths>
+data: '80,80,80'
+end tag: </column_widths>
+data: '\012 '
+start tag: <selection_mode>
+data: 'GTK_SELECTION_SINGLE'
+end tag: </selection_mode>
+data: '\012 '
+start tag: <show_titles>
+data: 'True'
+end tag: </show_titles>
+data: '\012 '
+start tag: <shadow_type>
+data: 'GTK_SHADOW_IN'
+end tag: </shadow_type>
+data: '\012 '
+start tag: <hscrollbar_policy>
+data: 'GTK_POLICY_AUTOMATIC'
+end tag: </hscrollbar_policy>
+data: '\012 '
+start tag: <vscrollbar_policy>
+data: 'GTK_POLICY_AUTOMATIC'
+end tag: </vscrollbar_policy>
+data: '\012\012 '
+start tag: <widget>
+data: '\012 '
+start tag: <class>
+data: 'GtkLabel'
+end tag: </class>
+data: '\012 '
+start tag: <child_name>
+data: 'CList:title'
+end tag: </child_name>
+data: '\012 '
+start tag: <name>
+data: 'label2'
+end tag: </name>
+data: '\012 '
+start tag: <label>
+data: 'Col1'
+end tag: </label>
+data: '\012 '
+start tag: <justify>
+data: 'GTK_JUSTIFY_CENTER'
+end tag: </justify>
+data: '\012 '
+start tag: <xalign>
+data: '0.5'
+end tag: </xalign>
+data: '\012 '
+start tag: <yalign>
+data: '0.5'
+end tag: </yalign>
+data: '\012 '
+start tag: <xpad>
+data: '0'
+end tag: </xpad>
+data: '\012 '
+start tag: <ypad>
+data: '0'
+end tag: </ypad>
+data: '\012 '
+end tag: </widget>
+data: '\012\012 '
+start tag: <widget>
+data: '\012 '
+start tag: <class>
+data: 'GtkLabel'
+end tag: </class>
+data: '\012 '
+start tag: <child_name>
+data: 'CList:title'
+end tag: </child_name>
+data: '\012 '
+start tag: <name>
+data: 'label3'
+end tag: </name>
+data: '\012 '
+start tag: <label>
+data: 'Col3'
+end tag: </label>
+data: '\012 '
+start tag: <justify>
+data: 'GTK_JUSTIFY_CENTER'
+end tag: </justify>
+data: '\012 '
+start tag: <xalign>
+data: '0.5'
+end tag: </xalign>
+data: '\012 '
+start tag: <yalign>
+data: '0.5'
+end tag: </yalign>
+data: '\012 '
+start tag: <xpad>
+data: '0'
+end tag: </xpad>
+data: '\012 '
+start tag: <ypad>
+data: '0'
+end tag: </ypad>
+data: '\012 '
+end tag: </widget>
+data: '\012\012 '
+start tag: <widget>
+data: '\012 '
+start tag: <class>
+data: 'GtkArrow'
+end tag: </class>
+data: '\012 '
+start tag: <child_name>
+data: 'CList:title'
+end tag: </child_name>
+data: '\012 '
+start tag: <name>
+data: 'arrow2'
+end tag: </name>
+data: '\012 '
+start tag: <arrow_type>
+data: 'GTK_ARROW_DOWN'
+end tag: </arrow_type>
+data: '\012 '
+start tag: <shadow_type>
+data: 'GTK_SHADOW_OUT'
+end tag: </shadow_type>
+data: '\012 '
+start tag: <xalign>
+data: '0.5'
+end tag: </xalign>
+data: '\012 '
+start tag: <yalign>
+data: '0.5'
+end tag: </yalign>
+data: '\012 '
+start tag: <xpad>
+data: '0'
+end tag: </xpad>
+data: '\012 '
+start tag: <ypad>
+data: '0'
+end tag: </ypad>
+data: '\012 '
+end tag: </widget>
+data: '\012 '
+end tag: </widget>
+data: '\012\012 '
+start tag: <widget>
+data: '\012 '
+start tag: <class>
+data: 'GtkNotebook'
+end tag: </class>
+data: '\012 '
+start tag: <name>
+data: 'notebook1'
+end tag: </name>
+data: '\012 '
+start tag: <child>
+data: '\012 '
+start tag: <left_attach>
+data: '0'
+end tag: </left_attach>
+data: '\012 '
+start tag: <right_attach>
+data: '3'
+end tag: </right_attach>
+data: '\012 '
+start tag: <top_attach>
+data: '0'
+end tag: </top_attach>
+data: '\012 '
+start tag: <bottom_attach>
+data: '1'
+end tag: </bottom_attach>
+data: '\012 '
+start tag: <xpad>
+data: '0'
+end tag: </xpad>
+data: '\012 '
+start tag: <ypad>
+data: '0'
+end tag: </ypad>
+data: '\012 '
+start tag: <xexpand>
+data: 'True'
+end tag: </xexpand>
+data: '\012 '
+start tag: <yexpand>
+data: 'True'
+end tag: </yexpand>
+data: '\012 '
+start tag: <xshrink>
+data: 'False'
+end tag: </xshrink>
+data: '\012 '
+start tag: <yshrink>
+data: 'False'
+end tag: </yshrink>
+data: '\012 '
+start tag: <xfill>
+data: 'True'
+end tag: </xfill>
+data: '\012 '
+start tag: <yfill>
+data: 'True'
+end tag: </yfill>
+data: '\012 '
+end tag: </child>
+data: '\012 '
+start tag: <can_focus>
+data: 'True'
+end tag: </can_focus>
+data: '\012 '
+start tag: <show_tabs>
+data: 'True'
+end tag: </show_tabs>
+data: '\012 '
+start tag: <show_border>
+data: 'True'
+end tag: </show_border>
+data: '\012 '
+start tag: <tab_pos>
+data: 'GTK_POS_TOP'
+end tag: </tab_pos>
+data: '\012 '
+start tag: <scrollable>
+data: 'False'
+end tag: </scrollable>
+data: '\012 '
+start tag: <tab_border>
+data: '3'
+end tag: </tab_border>
+data: '\012 '
+start tag: <popup_enable>
+data: 'False'
+end tag: </popup_enable>
+data: '\012\012 '
+start tag: <widget>
+data: '\012 '
+start tag: <class>
+data: 'GtkHRuler'
+end tag: </class>
+data: '\012 '
+start tag: <name>
+data: 'hruler1'
+end tag: </name>
+data: '\012 '
+start tag: <metric>
+data: 'GTK_PIXELS'
+end tag: </metric>
+data: '\012 '
+start tag: <lower>
+data: '0'
+end tag: </lower>
+data: '\012 '
+start tag: <upper>
+data: '10'
+end tag: </upper>
+data: '\012 '
+start tag: <position>
+data: '0'
+end tag: </position>
+data: '\012 '
+start tag: <max_size>
+data: '10'
+end tag: </max_size>
+data: '\012 '
+end tag: </widget>
+data: '\012\012 '
+start tag: <widget>
+data: '\012 '
+start tag: <class>
+data: 'GtkHScale'
+end tag: </class>
+data: '\012 '
+start tag: <name>
+data: 'hscale2'
+end tag: </name>
+data: '\012 '
+start tag: <can_focus>
+data: 'True'
+end tag: </can_focus>
+data: '\012 '
+start tag: <draw_value>
+data: 'True'
+end tag: </draw_value>
+data: '\012 '
+start tag: <value_pos>
+data: 'GTK_POS_TOP'
+end tag: </value_pos>
+data: '\012 '
+start tag: <digits>
+data: '1'
+end tag: </digits>
+data: '\012 '
+start tag: <policy>
+data: 'GTK_UPDATE_CONTINUOUS'
+end tag: </policy>
+data: '\012 '
+start tag: <hvalue>
+data: '0'
+end tag: </hvalue>
+data: '\012 '
+start tag: <hlower>
+data: '0'
+end tag: </hlower>
+data: '\012 '
+start tag: <hupper>
+data: '100'
+end tag: </hupper>
+data: '\012 '
+start tag: <hstep>
+data: '1'
+end tag: </hstep>
+data: '\012 '
+start tag: <hpage>
+data: '10'
+end tag: </hpage>
+data: '\012 '
+start tag: <hpage_size>
+data: '10'
+end tag: </hpage_size>
+data: '\012 '
+end tag: </widget>
+data: '\012\012 '
+start tag: <widget>
+data: '\012 '
+start tag: <class>
+data: 'GtkProgressBar'
+end tag: </class>
+data: '\012 '
+start tag: <name>
+data: 'progressbar1'
+end tag: </name>
+data: '\012 '
+end tag: </widget>
+data: '\012\012 '
+start tag: <widget>
+data: '\012 '
+start tag: <class>
+data: 'GtkLabel'
+end tag: </class>
+data: '\012 '
+start tag: <child_name>
+data: 'Notebook:tab'
+end tag: </child_name>
+data: '\012 '
+start tag: <name>
+data: 'label5'
+end tag: </name>
+data: '\012 '
+start tag: <label>
+data: 'label5'
+end tag: </label>
+data: '\012 '
+start tag: <justify>
+data: 'GTK_JUSTIFY_CENTER'
+end tag: </justify>
+data: '\012 '
+start tag: <xalign>
+data: '0.5'
+end tag: </xalign>
+data: '\012 '
+start tag: <yalign>
+data: '0.5'
+end tag: </yalign>
+data: '\012 '
+start tag: <xpad>
+data: '0'
+end tag: </xpad>
+data: '\012 '
+start tag: <ypad>
+data: '0'
+end tag: </ypad>
+data: '\012 '
+end tag: </widget>
+data: '\012\012 '
+start tag: <widget>
+data: '\012 '
+start tag: <class>
+data: 'GtkLabel'
+end tag: </class>
+data: '\012 '
+start tag: <child_name>
+data: 'Notebook:tab'
+end tag: </child_name>
+data: '\012 '
+start tag: <name>
+data: 'label6'
+end tag: </name>
+data: '\012 '
+start tag: <label>
+data: 'label6'
+end tag: </label>
+data: '\012 '
+start tag: <justify>
+data: 'GTK_JUSTIFY_CENTER'
+end tag: </justify>
+data: '\012 '
+start tag: <xalign>
+data: '0.5'
+end tag: </xalign>
+data: '\012 '
+start tag: <yalign>
+data: '0.5'
+end tag: </yalign>
+data: '\012 '
+start tag: <xpad>
+data: '0'
+end tag: </xpad>
+data: '\012 '
+start tag: <ypad>
+data: '0'
+end tag: </ypad>
+data: '\012 '
+end tag: </widget>
+data: '\012\012 '
+start tag: <widget>
+data: '\012 '
+start tag: <class>
+data: 'GtkLabel'
+end tag: </class>
+data: '\012 '
+start tag: <child_name>
+data: 'Notebook:tab'
+end tag: </child_name>
+data: '\012 '
+start tag: <name>
+data: 'label7'
+end tag: </name>
+data: '\012 '
+start tag: <label>
+data: 'label7'
+end tag: </label>
+data: '\012 '
+start tag: <justify>
+data: 'GTK_JUSTIFY_CENTER'
+end tag: </justify>
+data: '\012 '
+start tag: <xalign>
+data: '0.5'
+end tag: </xalign>
+data: '\012 '
+start tag: <yalign>
+data: '0.5'
+end tag: </yalign>
+data: '\012 '
+start tag: <xpad>
+data: '0'
+end tag: </xpad>
+data: '\012 '
+start tag: <ypad>
+data: '0'
+end tag: </ypad>
+data: '\012 '
+end tag: </widget>
+data: '\012 '
+end tag: </widget>
+data: '\012 '
+end tag: </widget>
+data: '\012'
+end tag: </widget>
+data: '\012\012'
+end tag: </GTK-Interface>
diff --git a/examples/ide/.cvsignore b/examples/ide/.cvsignore
new file mode 100644
index 00000000..c2831020
--- /dev/null
+++ b/examples/ide/.cvsignore
@@ -0,0 +1,6 @@
+Makefile.in
+Makefile
+*~
+*.pyc
+*.pyo
+
diff --git a/examples/ide/README b/examples/ide/README
new file mode 100644
index 00000000..99568b0f
--- /dev/null
+++ b/examples/ide/README
@@ -0,0 +1,7 @@
+This directory contains some tools that can be used to help develop python
+applications. There is a graphical front end to the profiler and debugger,
+and a graphical python console, and a 'module browser'.
+
+I will probably link these together with an editor (just use emacs, or write
+one in python?).
+
diff --git a/examples/ide/break.xpm b/examples/ide/break.xpm
new file mode 100644
index 00000000..f5221a30
--- /dev/null
+++ b/examples/ide/break.xpm
@@ -0,0 +1,29 @@
+/* XPM */
+static char * break_xpm[] = {
+"21 22 4 1",
+" c None",
+". c #000000",
+"X c #FFFFFF",
+"o c #FF0000",
+" ......... ",
+" .XXXXXXXXX. ",
+" .XXoooooooXX. ",
+" .XXoooooooooXX. ",
+" .XXoooooooooooXX. ",
+" .XXoooooooooooooXX. ",
+".XXoooooooooooooooXX.",
+".XoooooooooooooooooX.",
+".XooXXoXXXoXXooXXooX.",
+".XoXooXoXoXooXoXoXoX.",
+".XoXooooXoXooXoXoXoX.",
+".XooXXooXoXooXoXXooX.",
+".XooooXoXoXooXoXoooX.",
+".XoXooXoXoXooXoXoooX.",
+".XooXXooXooXXooXoooX.",
+".XXoooooooooooooooXX.",
+" .XXoooooooooooooXX. ",
+" .XXoooooooooooXX. ",
+" .XXoooooooooXX. ",
+" .XXoooooooXX. ",
+" .XXXXXXXXX. ",
+" ......... "};
diff --git a/examples/ide/browse.py b/examples/ide/browse.py
new file mode 100755
index 00000000..ba8e55d1
--- /dev/null
+++ b/examples/ide/browse.py
@@ -0,0 +1,117 @@
+#!/usr/bin/env python
+
+# This is an example of using dynamic trees (trees where nodes are only
+# calculated as they are needed) with pygtk. This particular example
+# allows for the browsing of the variables in a module, allowing the
+# descent into classes and modules and other objects with a __dict__
+# attribute.
+
+# If this file is run straight, it will let you browse the gtk module.
+
+from gtk import *
+
+class BrowseTreeItem(GtkTreeItem):
+ def __init__(self, name, dict=None, disp=None):
+ GtkTreeItem.__init__(self, name)
+ self.name = name
+ self.dict = dict
+ self.disp = disp
+ self.exp_id = self.connect("expand", self.sig_expand)
+ def init_subtree(self):
+ if self.dict:
+ self.subtree = GtkTree()
+ self.subtree.set_selection_mode(SELECTION_BROWSE)
+ self.subtree.connect("select_child", self.subsel_child)
+ self.set_subtree(self.subtree)
+ self.subtree.show()
+ def subsel_child(self, _t, _c):
+ if self.disp:
+ key = _c.children()[0].get()
+ if key == '__builtins__': # builtins includes itself
+ value = key
+ else:
+ value = `self.dict[key]`
+ self.disp.set_text(value)
+ def sig_select(self):
+ if self.disp:
+ self.disp.set_text(value)
+ def sig_expand(self, _t):
+ keys = self.dict.keys()
+ keys.sort()
+ for key in keys:
+ dict = None
+ try:
+ dict = vars(self.dict[key])
+ except TypeError:
+ pass
+ item = BrowseTreeItem(key, dict, self.disp)
+ self.subtree.append(item)
+ item.init_subtree()
+ item.show()
+ self.disconnect(self.exp_id)
+
+class BrowseVariables(GtkVBox):
+ def __init__(self, name, dict):
+ GtkVBox.__init__(self)
+ self.set_spacing(2)
+
+ self.sw = GtkScrolledWindow()
+ self.sw.set_usize(300, 200)
+ self.sw.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC)
+ self.pack_start(self.sw)
+ self.sw.show()
+
+ self.disp = GtkEntry()
+ self.disp.set_editable(FALSE)
+ self.pack_start(self.disp, expand=FALSE)
+ self.disp.show()
+
+ self.root_tree = GtkTree()
+ self.sw.add(self.root_tree)
+ self.root_tree.show()
+
+ self.browse = BrowseTreeItem(name, dict, self.disp)
+ self.root_tree.append(self.browse)
+ self.browse.init_subtree()
+ self.browse.show()
+
+class BrowseWindow(GtkWindow):
+ def __init__(self, name, dict):
+ GtkWindow.__init__(self)
+ self.set_title("Browse Window")
+
+ box = GtkVBox()
+ self.add(box)
+ box.show()
+
+ browse = BrowseVariables(name, dict)
+ browse.border_width(10)
+ box.pack_start(browse)
+ browse.show()
+
+ separator = GtkHSeparator()
+ box.pack_start(separator, expand=FALSE)
+ separator.show()
+
+ box2 = GtkVBox(spacing=10)
+ box2.border_width(10)
+ box.pack_start(box2, expand=FALSE)
+ box2.show()
+
+ button = GtkButton("Close")
+ box2.pack_start(button)
+ button.set_flags(CAN_DEFAULT)
+ button.grab_default()
+ button.show()
+ self.close_button = button
+
+if __name__ == '__main__':
+ import gtk
+ win = BrowseWindow('gtk', vars(gtk))
+ win.set_title("Browse gtk.py")
+ win.connect("destroy", mainquit)
+ win.connect("delete_event", mainquit)
+ win.close_button.connect("clicked", mainquit)
+ win.show()
+
+ mainloop()
diff --git a/examples/ide/continue.xpm b/examples/ide/continue.xpm
new file mode 100644
index 00000000..f44f61d7
--- /dev/null
+++ b/examples/ide/continue.xpm
@@ -0,0 +1,27 @@
+/* XPM */
+static char * continue_xpm[] = {
+"20 22 2 1",
+" c None",
+". c #000000",
+" ",
+" ",
+" . . ",
+" .. .. ",
+" ... ... ",
+" .... .... ",
+" ..... ..... ",
+" ...... ...... ",
+" ....... ....... ",
+" ........ ........ ",
+" .................. ",
+" .................. ",
+" ........ ........ ",
+" ....... ....... ",
+" ...... ...... ",
+" ..... ..... ",
+" .... .... ",
+" ... ... ",
+" .. .. ",
+" . . ",
+" ",
+" "};
diff --git a/examples/ide/edit.py b/examples/ide/edit.py
new file mode 100644
index 00000000..7b0f0349
--- /dev/null
+++ b/examples/ide/edit.py
@@ -0,0 +1,181 @@
+#!/usr/bin/env python
+
+# This is a sample implementation of an editor.
+
+from gtk import *
+import GtkExtra
+import os
+
+BLOCK_SIZE = 2048
+
+class EditWindow(GtkWindow):
+ def __init__(self, quit_cb=None):
+ GtkWindow.__init__(self, WINDOW_TOPLEVEL)
+ self.set_usize(470, 300)
+ self.connect("delete_event", self.file_exit)
+
+ self.quit_cb = quit_cb
+
+ self.table = GtkTable(2,3)
+ self.add(self.table)
+ self.table.show()
+ hdlbox = GtkHandleBox()
+ self.table.attach(hdlbox, 0,2, 0,1, xoptions=FILL,
+ yoptions=FILL)
+ hdlbox.show()
+ self.menubar = self.create_menu()
+ hdlbox.add(self.menubar)
+ self.menubar.show()
+
+ self.text = GtkText()
+ self.text.connect("changed", self.set_dirty)
+ self.text.set_editable(TRUE)
+ self.table.attach(self.text, 0,1, 1,2)
+ self.text.show()
+
+ vadj = self.text.get_vadjustment()
+ self.vscroll = GtkVScrollbar(vadj)
+ self.table.attach(self.vscroll, 1,2, 1,2, xoptions=FILL)
+ self.vscroll.show()
+ vadj.connect('changed', self.chk_scroll)
+
+ self.text.realize()
+ self.dirty = 0
+ self.file_new()
+ self.text.grab_focus()
+
+ def set_dirty(self, text=None):
+ self.dirty = 1
+ def chk_scroll(self, adj):
+ if adj.upper - adj.lower <= adj.page_size:
+ self.vscroll.hide()
+ else:
+ self.vscroll.show()
+
+ def load_file(self, fname):
+ try:
+ fd = open(fname)
+ self.text.freeze()
+ self.text.delete_text(0, self.text.get_length())
+ buf = fd.read(BLOCK_SIZE)
+ while buf != '':
+ self.text.insert_defaults(buf)
+ buf = fd.read(BLOCK_SIZE)
+ self.text.thaw()
+ self.text.get_vadjustment().set_value(0)
+ self.text.queue_draw()
+ self.set_title(os.path.basename(fname))
+ self.fname = fname
+ self.dirty = 0
+ self.new = 0
+ except:
+ GtkExtra.message_box('Edit', "Can't open " + fname,
+ ("OK",))
+
+ def create_menu(self):
+ mf = GtkExtra.MenuFactory()
+
+ mf.add_entries([
+ ('File/New', '<control>N', self.file_new),
+ ('File/Open...', '<control>O', self.file_open),
+ ('File/Save', '<control>S', self.file_save),
+ ('File/Save As...', None, self.file_saveas),
+ ('File/<separator>',None, None),
+ ('File/Exit', '<control>Q', self.file_exit),
+ ('Edit/Cut', '<control>X', self.edit_cut),
+ ('Edit/Copy', '<control>C', self.edit_copy),
+ ('Edit/Paste', '<control>V', self.edit_paste),
+ ('Edit/Clear', None, self.edit_clear),
+ ('Edit/<separator>',None, None),
+ ('Edit/Find...', None, self.edit_find),
+ ('Edit/Find Next', None, self.edit_find_next),
+ ('Help/About...', None, self.help_about)
+ ])
+ # activate key bindings ...
+ self.add_accel_group(mf.accelerator)
+ self.mf = mf
+ return mf
+
+ def chk_save(self):
+ if self.dirty:
+ ret = GtkExtra.message_box("Unsaved File",
+ (self.fname or "Untitled")+
+ " has not been saved\n" +
+ "Do you want to save it?",
+ ("Yes", "No", "Cancel"))
+ if ret == None or ret == "Cancel": return 1
+ if ret == "Yes": self.file_save()
+ return 0
+
+ def file_new(self, mi=None):
+ if self.chk_save(): return
+ self.text.freeze()
+ self.text.delete_text(0, self.text.get_length())
+ self.text.thaw()
+ self.dirty = 0
+ self.fname = None
+ self.set_title("Untitled")
+ self.new = 1
+ def file_open(self, mi=None):
+ if self.chk_save(): return
+ fname = GtkExtra.file_open_box(modal=FALSE)
+ if not fname: return
+ self.load_file(fname)
+ def file_save(self, mi=None):
+ if self.new:
+ self.file_saveas()
+ return
+ try:
+ pos = 0
+ length = self.text.get_length()
+ fd = open(self.fname, "w")
+ while pos < length:
+ buf = self.text.get_chars(pos,
+ min(pos+BLOCK_SIZE, length))
+ if buf != None: fd.write(buf)
+ pos = pos + BLOCK_SIZE
+ self.dirty = 0
+ except:
+ GtkExtra.message_box("Save", "Error saving file " +
+ self.fname, ("OK",))
+
+ def file_saveas(self, mi=None):
+ fname = GtkExtra.file_save_box(modal=FALSE)
+ if not fname: return
+ self.fname = fname
+ self.set_title(os.path.basename(fname))
+ self.new = 0
+ self.file_save()
+ def file_exit(self, mi=None, event=None):
+ if self.chk_save(): return
+ self.hide()
+ self.destroy()
+ if self.quit_cb: self.quit_cb(self)
+ def edit_cut(self, mi):
+ self.text.cut_clipboard(0)
+ def edit_copy(self, mi):
+ self.text.copy_clipboard(0)
+ def edit_paste(self, mi):
+ self.text.paste_clipboard(0)
+ def edit_clear(self, mi):
+ self.text.delete_selection()
+ # I'll implement these later
+ def edit_find(self, mi): pass
+ def edit_find_next(self, mi): pass
+ def help_about(self, mi):
+ GtkExtra.message_box("Edit Window", "Copyright (C) 1998 " +
+ "James Henstridge\n" +
+ "This program is covered by the GPL>=2",
+ ("OK",))
+
+def edit(fname, mainwin=FALSE):
+ if mainwin: quit_cb = mainquit
+ else: quit_cb = None
+ w = EditWindow(quit_cb=quit_cb)
+ w.load_file(fname)
+ w.show()
+ w.set_usize(0,0)
+ if mainwin: mainloop()
+if __name__ == '__main__':
+ import sys
+ edit(sys.argv[-1], mainwin=TRUE)
diff --git a/examples/ide/edit.xpm b/examples/ide/edit.xpm
new file mode 100644
index 00000000..a2291f36
--- /dev/null
+++ b/examples/ide/edit.xpm
@@ -0,0 +1,38 @@
+/* XPM */
+static char *edit[] = {
+/* width height num_colors chars_per_pixel */
+" 20 22 8 1",
+/* colors */
+". c #ffffff",
+"# c None",
+"a c #9999ff",
+"b c #999999",
+"c c #6666cc",
+"d c #663399",
+"e c #333333",
+"f c #000000",
+/* pixels */
+"eeeeeeeeeeeee#######",
+"e..........e.e######",
+"e..........e..eeffff",
+"e..........e.effadf#",
+"e..........effacdf##",
+"e.........ffaccdff##",
+"e........facccdfbf##",
+"e.......faccddfbbf##",
+"e......faccddf..bf##",
+"e.....faccddf...bf##",
+"e....faccddf....bf##",
+"e...eaccddf.....bf##",
+"e...facddf......bf##",
+"e..eacddf.......bf##",
+"e..faeff........bf##",
+"e.eaeb..........bf##",
+"e.feb...........bf##",
+"e.fb............bf##",
+"e.f.............bf##",
+"e...............bf##",
+"eebbbbbbbbbbbbbbef##",
+"##ffffffffffffffff##"
+};
+
diff --git a/examples/ide/gtkcons.py b/examples/ide/gtkcons.py
new file mode 100755
index 00000000..140dca93
--- /dev/null
+++ b/examples/ide/gtkcons.py
@@ -0,0 +1,329 @@
+#!/usr/bin/env python
+
+# Interactive Python-GTK Console
+# Copyright (C), 1998 James Henstridge <james@daa.com.au>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+# This module implements an interactive python session in a GTK window. To
+# start the session, use the gtk_console command. Its specification is:
+# gtk_console(namespace, title, copyright)
+# where namespace is a dictionary representing the namespace of the session,
+# title is the title on the window and
+# copyright is any additional copyright info to print.
+#
+# As well as the starting attributes in namespace, the session will also
+# have access to the list __history__, which is the command history.
+
+import sys, string, traceback
+#sys.path.append('/home/james/.gimp/plug-ins')
+from gtk import *
+
+stdout = sys.stdout
+
+if not hasattr(sys, 'ps1'): sys.ps1 = '>>> '
+if not hasattr(sys, 'ps2'): sys.ps2 = '... '
+
+# some functions to help recognise breaks between commands
+def remQuotStr(s):
+ '''Returns s with any quoted strings removed (leaving quote marks)'''
+ r = ''
+ inq = 0
+ qt = ''
+ prev = '_'
+ while len(s):
+ s0, s = s[0], s[1:]
+ if inq and (s0 != qt or prev == '\\'):
+ prev = s0
+ continue
+ prev = s0
+ if s0 in '\'"':
+ if inq:
+ inq = 0
+ else:
+ inq = 1
+ qt = s0
+ r = r + s0
+ return r
+
+def bracketsBalanced(s):
+ '''Returns true iff the brackets in s are balanced'''
+ s = filter(lambda x: x in '()[]{}', s)
+ stack = []
+ brackets = {'(':')', '[':']', '{':'}'}
+ while len(s) != 0:
+ if s[0] in ")]}":
+ if len(stack) != 0 and brackets[stack[-1]] == s[0]:
+ del stack[-1]
+ else:
+ return 0
+ else:
+ stack.append(s[0])
+ s = s[1:]
+ return len(stack) == 0
+
+class gtkoutfile:
+ '''A fake output file object. It sends output to a TK test widget,
+ and if asked for a file number, returns one set on instance creation'''
+ def __init__(self, w, fn, font):
+ self.__fn = fn
+ self.__w = w
+ self.__font = font
+ def close(self): pass
+ flush = close
+ def fileno(self): return self.__fn
+ def isatty(self): return 0
+ def read(self, a): return ''
+ def readline(self): return ''
+ def readlines(self): return []
+ def write(self, s):
+ #stdout.write(str(self.__w.get_point()) + '\n')
+ self.__w.freeze()
+ self.__w.insert(self.__font, self.__w.fg,
+ self.__w.bg, s)
+ self.__w.thaw()
+ self.__w.queue_draw()
+ def writelines(self, l):
+ self.__w.freeze()
+ for s in l: self.__w.insert(self.__font,
+ self.__w.fg, self.__w.bg, s)
+ self.__w.thaw()
+ self.__w.queue_draw()
+ def seek(self, a): raise IOError, (29, 'Illegal seek')
+ def tell(self): raise IOError, (29, 'Illegal seek')
+ truncate = tell
+
+class Console(GtkVBox):
+ def __init__(self, namespace={}, copyright='', quit_cb=None):
+ GtkVBox.__init__(self, spacing=2)
+ self.border_width(2)
+ self.copyright = copyright
+ #self.set_usize(475, 300)
+
+ self.quit_cb = quit_cb
+
+ #load the fonts we will use
+ self.normal = load_font(
+ "-*-helvetica-medium-r-normal-*-*-100-*-*-*-*-*-*")
+ self.title = load_font(
+ "-*-helvetica-bold-r-normal-*-*-100-*-*-*-*-*-*")
+ self.error = load_font(
+ "-*-helvetica-medium-o-normal-*-12-100-*-*-*-*-*-*")
+ self.command = load_font(
+ "-*-helvetica-bold-r-normal-*-*-100-*-*-*-*-*-*")
+
+ self.inp = GtkHBox()
+ self.pack_start(self.inp)
+ self.inp.show()
+
+ self.text = GtkText()
+ self.text.set_editable(FALSE)
+ self.text.set_word_wrap(TRUE)
+ self.text.set_usize(500, 400)
+ self.inp.pack_start(self.text, padding=1)
+ self.text.show()
+
+ self.vscroll = GtkVScrollbar(self.text.get_vadjustment())
+ self.vscroll.set_update_policy(POLICY_AUTOMATIC)
+ self.inp.pack_end(self.vscroll, expand=FALSE)
+ self.vscroll.show()
+
+ self.inputbox = GtkHBox(spacing=2)
+ self.pack_end(self.inputbox, expand=FALSE)
+ self.inputbox.show()
+
+ self.prompt = GtkLabel(sys.ps1)
+ self.prompt.set_padding(xp=2, yp=0)
+ self.prompt.set_usize(26, -1)
+ self.inputbox.pack_start(self.prompt, fill=FALSE, expand=FALSE)
+ self.prompt.show()
+
+ self.closer = GtkButton("Close")
+ self.closer.connect("clicked", self.quit)
+ self.inputbox.pack_end(self.closer, fill=FALSE, expand=FALSE)
+ self.closer.show()
+
+ self.line = GtkEntry()
+ self.line.set_usize(400,-1)
+ self.line.connect("key_press_event", self.key_function)
+ self.inputbox.pack_start(self.line, padding=2)
+ self.line.show()
+
+ # now let the text box be resized
+ self.text.set_usize(0, 0)
+ self.line.set_usize(0, -1)
+
+ self.namespace = namespace
+
+ self.cmd = ''
+ self.cmd2 = ''
+
+ # set up hooks for standard output.
+ self.stdout = gtkoutfile(self.text, sys.stdout.fileno(),
+ self.normal)
+ self.stderr = gtkoutfile(self.text, sys.stderr.fileno(),
+ self.error)
+
+ # set up command history
+ self.history = ['']
+ self.histpos = 0
+ self.namespace['__history__'] = self.history
+
+ def init(self):
+ self.text.realize()
+ self.text.style = self.text.get_style()
+ self.text.fg = self.text.style.fg[STATE_NORMAL]
+ self.text.bg = self.text.style.white
+
+ self.text.insert(self.title, self.text.fg,
+ self.text.bg, 'Python %s\n%s\n\n' %
+ (sys.version, sys.copyright) +
+ 'Interactive Python-GTK Console - ' +
+ 'Copyright (C) 1998 James Henstridge\n\n' +
+ self.copyright + '\n')
+ self.line.grab_focus()
+
+ def quit(self, *args):
+ self.hide()
+ self.destroy()
+ if self.quit_cb: self.quit_cb()
+
+ def key_function(self, entry, event):
+ if event.keyval == GDK.Return:
+ self.line.emit_stop_by_name("key_press_event")
+ self.eval()
+ if event.keyval == GDK.Tab:
+ self.line.emit_stop_by_name("key_press_event")
+ self.line.append_text('\t')
+ idle_add(self.focus_text)
+ elif event.keyval in (GDK.KP_Up, GDK.Up):
+ self.line.emit_stop_by_name("key_press_event")
+ self.historyUp()
+ idle_add(self.focus_text)
+ elif event.keyval in (GDK.KP_Down, GDK.Down):
+ self.line.emit_stop_by_name("key_press_event")
+ self.historyDown()
+ idle_add(self.focus_text)
+ elif event.keyval in (GDK.D, GDK.d) and \
+ event.state & GDK.CONTROL_MASK:
+ self.line.emit_stop_by_name("key_press_event")
+ self.ctrld()
+
+ def focus_text(self):
+ self.line.grab_focus()
+ return FALSE # don't requeue this handler
+
+ def ctrld(self):
+ self.quit()
+
+ def historyUp(self):
+ if self.histpos > 0:
+ l = self.line.get_text()
+ if len(l) > 0 and l[0] == '\n': l = l[1:]
+ if len(l) > 0 and l[-1] == '\n': l = l[:-1]
+ self.history[self.histpos] = l
+ self.histpos = self.histpos - 1
+ self.line.set_text(self.history[self.histpos])
+
+ def historyDown(self):
+ if self.histpos < len(self.history) - 1:
+ l = self.line.get_text()
+ if len(l) > 0 and l[0] == '\n': l = l[1:]
+ if len(l) > 0 and l[-1] == '\n': l = l[:-1]
+ self.history[self.histpos] = l
+ self.histpos = self.histpos + 1
+ self.line.set_text(self.history[self.histpos])
+
+ def eval(self):
+ l = self.line.get_text() + '\n'
+ if len(l) > 1 and l[0] == '\n': l = l[1:]
+ self.histpos = len(self.history) - 1
+ if len(l) > 0 and l[-1] == '\n':
+ self.history[self.histpos] = l[:-1]
+ else:
+ self.history[self.histpos] = l
+ self.line.set_text('')
+ self.text.freeze()
+ self.text.insert(self.command, self.text.fg, self.text.bg,
+ self.prompt.get() + l)
+ self.text.thaw()
+ if l == '\n':
+ self.run(self.cmd)
+ self.cmd = ''
+ self.cmd2 = ''
+ return
+ self.histpos = self.histpos + 1
+ self.history.append('')
+ self.cmd = self.cmd + l
+ self.cmd2 = self.cmd2 + remQuotStr(l)
+ l = string.rstrip(l)
+ if not bracketsBalanced(self.cmd2) or l[-1] == ':' or \
+ l[-1] == '\\' or l[0] in ' \11':
+ self.prompt.set(sys.ps2)
+ self.prompt.queue_draw()
+ return
+ self.run(self.cmd)
+ self.cmd = ''
+ self.cmd2 = ''
+
+ def run(self, cmd):
+ sys.stdout, self.stdout = self.stdout, sys.stdout
+ sys.stderr, self.stderr = self.stderr, sys.stderr
+ try:
+ try:
+ r = eval(cmd, self.namespace, self.namespace)
+ if r is not None:
+ print `r`
+ except SyntaxError:
+ exec cmd in self.namespace
+ except:
+ if hasattr(sys, 'last_type') and \
+ sys.last_type == SystemExit:
+ self.quit()
+ else:
+ traceback.print_exc()
+ self.prompt.set(sys.ps1)
+ self.prompt.queue_draw()
+ adj = self.text.get_vadjustment()
+ adj.set_value(adj.upper - adj.page_size)
+ sys.stdout, self.stdout = self.stdout, sys.stdout
+ sys.stderr, self.stderr = self.stderr, sys.stderr
+
+def gtk_console(ns, title='Python', copyright='', menu=None):
+ win = GtkWindow()
+ win.set_usize(475, 300)
+ win.connect("destroy", mainquit)
+ win.connect("delete_event", mainquit)
+ win.set_title(title)
+ cons = Console(namespace=ns, copyright=copyright, quit_cb=mainquit)
+ if menu:
+ box = GtkVBox()
+ win.add(box)
+ box.show()
+ box.pack_start(menu, expand=FALSE)
+ menu.show()
+ box.pack_start(cons)
+ else:
+ win.add(cons)
+ cons.show()
+ win.show()
+ win.set_usize(0,0)
+ cons.init()
+ mainloop()
+
+if __name__ == '__main__':
+ gtk_console({'__builtins__': __builtins__, '__name__': '__main__',
+ '__doc__': None})
+
diff --git a/examples/ide/gtkdb.py b/examples/ide/gtkdb.py
new file mode 100755
index 00000000..6874d34b
--- /dev/null
+++ b/examples/ide/gtkdb.py
@@ -0,0 +1,350 @@
+#!/usr/bin/env python
+
+import sys
+import bdb
+import repr
+import string
+import linecache # for linecache.getlines(filename)
+from gtk import *
+import GtkExtra
+
+class GtkDb(GtkWindow, bdb.Bdb):
+ def __init__(self):
+ GtkWindow.__init__(self)
+ bdb.Bdb.__init__(self)
+ self.realize()
+
+ self.set_title("GtkDb")
+ self.connect("destroy", self.do_quit)
+ self.connect("delete_event", self.do_quit)
+
+ self.box = GtkVBox()
+ self.add(self.box)
+ self.box.show()
+
+ toolbar = GtkToolbar(ORIENTATION_HORIZONTAL, TOOLBAR_BOTH)
+ toolbar.set_space_size(10)
+ self.box.pack_start(toolbar, expand=FALSE)
+ toolbar.show()
+
+ toolbar.append_item("next", "Next statement", None,
+ GtkPixmap(self, "next.xpm"), self.do_next)
+ toolbar.append_item("step", "Step into function", None,
+ GtkPixmap(self, "step.xpm"), self.do_step)
+ toolbar.append_space()
+ toolbar.append_item("return",
+ "Continue execution to end of function",
+ None, GtkPixmap(self, "return.xpm"),
+ self.do_return)
+ toolbar.append_space()
+ toolbar.append_item("continue",
+ "Continue execution to next break point",
+ None, GtkPixmap(self, "continue.xpm"),
+ self.do_continue)
+ toolbar.append_item("break",
+ "toggle break point at selected line",None,
+ GtkPixmap(self,"break.xpm"),self.do_break)
+ toolbar.append_space()
+ toolbar.append_item("edit",
+ "edit the value of the selected variable",
+ None, GtkPixmap(self, "edit.xpm"),
+ self.do_edit)
+ toolbar.append_item("run",
+ "Execute some code in the current stack context",
+ None, GtkPixmap(self, "run.xpm"),
+ self.do_run)
+ toolbar.append_space()
+ toolbar.append_item("quit", "Quit the debugger", None,
+ GtkPixmap(self, "quit.xpm"), self.do_quit)
+
+ sep = GtkHSeparator()
+ self.box.pack_start(sep, expand=FALSE)
+ sep.show()
+
+ vpane = GtkVPaned()
+ self.box.pack_start(vpane)
+ vpane.show()
+
+ hpane = GtkHPaned()
+ vpane.add1(hpane)
+ hpane.show()
+
+ self.stackdisp = GtkCList(1, ['Stack Frame'])
+ self.stackdisp.connect("select_row", self.update_curstack)
+ self.stackdisp.set_usize(280, 125)
+ self.stackdisp.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC)
+ self.stackdisp.set_selection_mode(SELECTION_BROWSE)
+ self.stackdisp.border_width(2)
+ hpane.add1(self.stackdisp)
+ self.stackdisp.show()
+
+ self.vardisp = GtkCList(3, ['local var', 'type', 'value'])
+ self.vardisp.connect("select_row", self.update_selectedvar)
+ self.vardisp.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC)
+ self.vardisp.set_selection_mode(SELECTION_BROWSE)
+ self.vardisp.set_column_width(0, 75)
+ self.vardisp.set_column_width(1, 30)
+ self.vardisp.border_width(2)
+ hpane.add2(self.vardisp)
+ self.vardisp.show()
+ self.vardisp.selected = 0
+ self.vardisp.varnames = []
+
+ self.filedisp = GtkCList(3, ['break', 'lineno', 'line'])
+ self.minibreak = GtkPixmap(self, "minibreak.xpm")
+ # This is giving a warning -- probably a bug in GTK
+ self.filedisp.set_column_widget(0, self.minibreak)
+ self.filedisp.column_titles_show()
+ self.filedisp.set_column_width(0, 14)
+ self.filedisp.set_column_width(1, 35)
+ self.filedisp.connect("select_row", self.update_selection)
+ self.filedisp.set_column_justification(1, JUSTIFY_RIGHT)
+ self.filedisp.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC)
+ self.filedisp.set_selection_mode(SELECTION_BROWSE)
+ self.filedisp.border_width(2)
+ self.filedisp.set_usize(600, 200)
+ vpane.add2(self.filedisp)
+ self.filedisp.show()
+
+ separator = GtkHSeparator()
+ self.box.pack_start(separator, expand=FALSE)
+ separator.show()
+
+ align = GtkAlignment(0.0, 0.5, 0.0, 0.0)
+ self.box.pack_start(align, expand=FALSE)
+ align.show()
+ self.status = GtkLabel()
+ self.status.set_padding(4, 1)
+ align.add(self.status)
+ self.status.show()
+
+ self.filename = None
+ self.selected = 0
+ self.blockupdate = 0
+
+ def set_status(self, str):
+ self.status.set(str)
+
+ def update_selection(self, clist, r, c, event):
+ if self.blockupdate: return
+ self.selected = r + 1
+ if c == 0: # break point column
+ self.do_break()
+
+ def update_curstack(self, clist, r, c, event):
+ if self.blockupdate: return
+ self.curindex = r
+ self.curframe = self.stack[self.curindex][0]
+ self.lineno = None
+ self.update_code_listing()
+ self.update_var_listing()
+
+ def update_selectedvar(self, clist, r, c, event):
+ self.vardisp.selected = r
+
+ def set_quit(self):
+ self.hide()
+ self.destroy()
+ bdb.Bdb.set_quit(self)
+
+ def reset(self):
+ bdb.Bdb.reset(self)
+ self.forget()
+ def forget(self):
+ self.lineno = None
+ self.stack = []
+ self.curindex = 0
+ self.curframe = None
+ def setup(self, f, t):
+ self.forget()
+ self.stack, self.curindex = self.get_stack(f, t)
+ self.curframe = self.stack[self.curindex][0]
+
+ # interaction functions -- overriden from bdb
+ def user_line(self, frame):
+ # called when we stop or break at this line
+ self.interaction(frame, None)
+ def user_return(self, frame, return_value):
+ # called when a return trap is set here
+ frame.f_locals['__return__'] = return_value
+ if frame.f_code.co_name:
+ func = frame.f_code.co_name
+ else:
+ func = "<lambda>"
+ self.set_status(func + " rerturned " + repr.repr(return_value))
+ self.interaction(frame, None)
+ def user_exception(self, frame, (exc_type, exc_value, exc_traceback)):
+ frame.f_locals['__exception__'] = exc_type, exc_value
+ if type(exc_type) == type(''):
+ exc_type_name = exc_type
+ else: exc_type_name = exc_type.__name__
+ self.set_status(exc_type_name + ':' + repr.repr(exc_value))
+ self.interaction(frame, exc_traceback)
+
+ def interaction(self, frame, traceback):
+ self.setup(frame, traceback)
+ self.update_stack_listing(self.curindex)
+ mainloop()
+ self.forget()
+
+ def update_stack_listing(self, curindex):
+ self.stackdisp.freeze()
+ self.blockupdate = 1
+ self.stackdisp.clear()
+ for i in range(len(self.stack)):
+ frame_lineno = self.stack[i]
+ row = self.format_stack_entry(frame_lineno, "##!##")
+ row = string.split(row, "##!##")[0]
+ self.stackdisp.append([row])
+ self.blockupdate = 0
+ self.stackdisp.moveto(curindex, 0, 1.0, 0.0)
+ self.stackdisp.select_row(curindex, 0)
+ self.stackdisp.thaw()
+
+ def update_var_listing(self):
+ self.vardisp.freeze()
+ self.vardisp.clear()
+ locals = self.curframe.f_locals
+ self.vardisp.varnames = locals.keys()
+ self.vardisp.varnames.sort()
+ for var in self.vardisp.varnames:
+ row = [var, type(locals[var]).__name__, repr.repr(
+ locals[var])]
+ self.vardisp.append(row)
+ self.vardisp.thaw()
+
+ def update_code_listing(self):
+ frame = self.curframe
+ newfile = frame.f_code.co_filename
+ if newfile != self.filename:
+ lines = linecache.getlines(newfile)
+ self.filename = newfile
+ self.filedisp.freeze()
+ self.blockupdate = 1
+ self.filedisp.clear()
+ breaks = self.get_file_breaks(newfile)
+ for line in range(len(lines)):
+ self.filedisp.append(['', repr.repr(line+1),
+ lines[line]])
+ if line+1 in breaks:
+ self.filedisp.set_pixmap(line, 0,
+ self.minibreak)
+ self.blockupdate = 0
+ self.filedisp.thaw()
+ self.selected = frame.f_lineno
+ lineno = self.selected
+ self.filedisp.moveto(lineno - 1, 2)
+ self.filedisp.select_row(lineno - 1, 2)
+
+ def do_next(self, _b=None):
+ self.set_next(self.curframe)
+ mainquit()
+ def do_step(self, _b=None):
+ self.set_step()
+ mainquit()
+ def do_return(self, _b=None):
+ self.set_return(self.curframe)
+ mainquit()
+ def do_continue(self, _b=None):
+ self.set_continue()
+ mainquit()
+ def do_quit(self, _b=None, _e=None):
+ self.set_quit()
+ mainquit()
+ def do_break(self, _b=None):
+ breaks = self.get_file_breaks(self.filename)
+ if self.selected in breaks:
+ err = self.clear_break(self.filename, self.selected)
+ if err:
+ self.set_status(err)
+ return
+ self.filedisp.set_text(self.selected-1, 0, ' ')
+ else:
+ err = self.set_break(self.filename, self.selected)
+ if err:
+ self.set_status(err)
+ return
+ self.filedisp.set_pixmap(self.selected-1, 0,
+ self.minibreak)
+ def do_run(self, _b=None):
+ line = GtkExtra.input_box("Execute Code",
+ "Enter code to execute:")
+ if line == None: return
+ locals = self.curframe.f_locals
+ globals = self.curframe.f_globals
+ globals['__privileged__'] = 1
+ try:
+ code = compile(line + '\n', '<stdin>', 'single')
+ exec code in globals, locals
+ except:
+ if type(sys.exc_type) == type(''):
+ exc_type_name = sys.exc_type
+ else: exc_type_name = sys.exc_type.__name__
+ self.set_status('*** ' + exc_type_name + ': ' +
+ str(sys.exc_value))
+ return
+ self.update_var_listing()
+
+ def do_edit(self, _b=None):
+ locals = self.curframe.f_locals
+ varname = self.vardisp.varnames[self.vardisp.selected]
+ val = repr.repr(locals[varname])
+ value = GtkExtra.input_box("Edit Variable",
+ "Enter new value for" + varname + ":", val)
+ if value == None: return
+ globals = self.curframe.f_globals
+ globals['__privileged__'] = 1
+ try:
+ val = eval(value, globals, locals)
+ self.curframe.f_locals[varname] = val
+ except:
+ if type(sys.exc_type) == type(''):
+ exc_type_name = sys.exc_type
+ else: exc_type_name = sys.exc_type.__name__
+ self.set_status('*** ' + exc_type_name + ': ' +
+ str(sys.exc_value))
+ return
+ row = self.vardisp.selected
+ self.vardisp.set_text(row, 1, type(val).__name__)
+ self.vardisp.set_text(row, 2, repr.repr(val))
+
+# this makes up the interface that is compatible with pdb.
+def run(statement, globals=None, locals=None):
+ win = GtkDb()
+ win.show()
+ win.run(statement, globals, locals)
+
+def runeval(expression, globals=None, locals=None):
+ win = GtkDb()
+ win.show()
+ return win.runeval(expression, globals, locals)
+
+def runcall(*args):
+ win = GtkDb()
+ win.show()
+ return apply(win.runcall, args)
+
+def set_trace():
+ win = GtkDb()
+ win.show()
+ win.set_trace()
+
+def post_mortem(traceback):
+ win = GtkDb()
+ win.show()
+ win.reset()
+ win.interaction(None, traceback)
+
+def pm():
+ post_mortem(sys.last_traceback)
+
+if __name__ == '__main__':
+ import os
+ if not sys.argv[1:]:
+ print "usage: gtkdb.py scriptfile [args ...]"
+ sys.exit(2)
+ filename = sys.argv[1]
+ del sys.argv[0] # delete gtkdb.py
+ sys.path.insert(0, os.path.dirname(filename))
+
+ run('execfile("' + filename + '")', {'__name__': '__main__'})
diff --git a/examples/ide/gtkprof.py b/examples/ide/gtkprof.py
new file mode 100755
index 00000000..c005e166
--- /dev/null
+++ b/examples/ide/gtkprof.py
@@ -0,0 +1,133 @@
+#!/usr/bin/env python
+
+import profile, pstats, fpformat
+
+from gtk import *
+
+class PStatWindow(GtkWindow):
+ def __init__(self, stats):
+ GtkWindow.__init__(self)
+ self.connect("destroy", self.quit)
+ self.connect("delete_event", self.quit)
+ self.set_title("Profile Statistics")
+
+ self.stats = stats
+
+ box1 = GtkVBox()
+ self.add(box1)
+ box1.show()
+
+ text = `stats.total_calls` + " function calls "
+ if stats.total_calls != stats.prim_calls:
+ text = text + "( " + `stats.prim_calls` + \
+ " primitive calls) "
+ text = text + "in " + fpformat.fix(stats.total_tt, 3) + \
+ " CPU seconds"
+ label = GtkLabel(text)
+ label.set_padding(2, 2)
+ box1.pack_start(label, expand=FALSE)
+ label.show()
+
+ titles = ['ncalls', 'tottime', 'percall', 'cumtime',
+ 'percall', 'filename:lineno(function)']
+ clist = GtkCList(len(titles), titles)
+ clist.set_column_width(0, 40)
+ clist.set_column_width(1, 50)
+ clist.set_column_width(2, 50)
+ clist.set_column_width(3, 50)
+ clist.set_column_width(4, 50)
+ clist.set_usize(500, 200)
+ clist.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC)
+ self.clist = clist
+ clist.border_width(10)
+ box1.pack_start(clist)
+ clist.show()
+
+ for i in range(5):
+ clist.set_column_justification(i, JUSTIFY_RIGHT)
+
+ self.insert_stats()
+
+ separator = GtkHSeparator()
+ box1.pack_start(separator, expand=FALSE)
+ separator.show()
+
+ box2 = GtkVBox(spacing=10)
+ box2.border_width(10)
+ box1.pack_start(box2, expand=FALSE)
+ box2.show()
+
+ button = GtkButton("close")
+ button.connect("clicked", self.quit)
+ self.close_button = button
+ box2.pack_start(button)
+ button.set_flags(CAN_DEFAULT)
+ button.grab_default()
+ button.show()
+
+ def quit(self, *args):
+ self.hide()
+ self.destroy()
+ mainquit()
+
+ def get_stats_list(self):
+ if self.stats.fcn_list:
+ return self.stats.fcn_list[:]
+ else:
+ return sekf.stats.stats.keys()
+
+ def insert_stats(self):
+ list = self.get_stats_list()
+ if list:
+ row = [None] * 6
+ self.clist.clear()
+ self.clist.freeze()
+ for func in list:
+ cc,nc,tt,ct,callers = self.stats.stats[func]
+ row[0] = `nc`
+ if nc != cc:
+ row[0] = row[0] + '/' + `cc`
+ row[1] = fpformat.fix(tt, 3)
+ if nc == 0:
+ row[2] = ''
+ else:
+ row[2] = fpformat.fix(tt/nc, 3)
+ row[3] = fpformat.fix(ct, 3)
+ if cc == 0:
+ row[4] = ''
+ else:
+ row[4] = fpformat.fix(ct/cc, 3)
+ file,line,name = func
+ row[5] = file + ":" + `line` + "(" + name + \
+ ")"
+ self.clist.append(row)
+ self.clist.thaw()
+
+
+def run(cmd):
+ prof = profile.Profile()
+ try:
+ stats = pstats.Stats(prof.run(cmd))
+ except SystemExit:
+ pass
+ stats.strip_dirs().sort_stats("time", "module", "name")
+ win = PStatWindow(stats)
+ win.show()
+ mainloop()
+
+def run_file(file):
+ return run('execfile("' + file + '")')
+
+
+if __name__ == '__main__':
+ import sys, os
+ if not sys.argv[1:]:
+ print "usage: gtkprof.py scriptfile [args ...]"
+ sys.exit(2)
+ filename = sys.argv[1]
+ del sys.argv[0]
+ sys.path.insert(0, os.path.dirname(filename))
+
+ run_file(filename)
+
+
diff --git a/examples/ide/minibreak.xpm b/examples/ide/minibreak.xpm
new file mode 100644
index 00000000..6fd11e7c
--- /dev/null
+++ b/examples/ide/minibreak.xpm
@@ -0,0 +1,19 @@
+/* XPM */
+static char * minibreak_xpm[] = {
+"12 12 4 1",
+" c None",
+". c #000000",
+"X c #FF0000",
+"o c #FFFFFF",
+" ...... ",
+" .oooooo. ",
+" .ooXXXXoo. ",
+".ooXXXXXXoo.",
+".oXXXXXXXXo.",
+".oXXXXXXXXo.",
+".oXXXXXXXXo.",
+".oXXXXXXXXo.",
+".ooXXXXXXoo.",
+" .ooXXXXoo. ",
+" .oooooo. ",
+" ...... "};
diff --git a/examples/ide/next.xpm b/examples/ide/next.xpm
new file mode 100644
index 00000000..6c0cf361
--- /dev/null
+++ b/examples/ide/next.xpm
@@ -0,0 +1,32 @@
+/* XPM */
+static char *next[] = {
+/* width height num_colors chars_per_pixel */
+" 20 22 2 1",
+/* colors */
+". c None",
+"# c #000000",
+/* pixels */
+"....................",
+"....................",
+"......#.............",
+"......##............",
+"......###...........",
+"......####..........",
+"......#####.........",
+"......######........",
+"......#######.......",
+"......########......",
+"......#########.....",
+"......#########.....",
+"......########......",
+"......#######.......",
+"......######........",
+"......#####.........",
+"......####..........",
+"......###...........",
+"......##............",
+"......#.............",
+"....................",
+"...................."
+};
+
diff --git a/examples/ide/pyide.py b/examples/ide/pyide.py
new file mode 100755
index 00000000..545ec4cd
--- /dev/null
+++ b/examples/ide/pyide.py
@@ -0,0 +1,180 @@
+#!/usr/bin/env python
+
+from gtk import *
+import GtkExtra
+import gtkcons, gtkdb, gtkprof, edit
+import os, sys, string
+
+# select a good VT emulator
+for vt in 'Eterm', 'nxterm', 'xterm-color', 'xterm', 'rxvt':
+ for dirname in string.split(os.environ['PATH'], os.pathsep):
+ fullname = os.path.join(dirname, vt)
+ if os.path.exists(fullname):
+ VT_CMD = fullname + ' -geometry 80x6 -e '
+ break
+ else:
+ continue
+ break
+else:
+ VT_CMD='' # this is not ideal
+
+class Application(GtkWindow):
+ def __init__(self):
+ GtkWindow.__init__(self, WINDOW_TOPLEVEL)
+ self.connect("destroy", self.quit)
+ self.connect("delete_event", self.quit)
+ self.set_title("Python")
+ self.set_usize(475, 325)
+ self.main_box = GtkVBox()
+ self.add(self.main_box)
+ self.main_box.show()
+ hdlbox = GtkHandleBox()
+ self.main_box.pack_start(hdlbox, expand=FALSE)
+ hdlbox.show()
+ mf = GtkExtra.MenuFactory()
+ mf.add_entries([
+ ('File/New', '<control>N', self.file_new),
+ ('File/Open...', '<control>O', self.file_open),
+ ('File/<separator>', None, None),
+ ('File/Exit', '<control>Q', self.file_exit),
+ ('Edit/Copy', '<control>C', self.edit_copy),
+ ('Edit/Paste', '<control>V', self.edit_paste),
+ ('Edit/Clear', None, self.edit_clear),
+ ('Python/Reload Module...', None, self.python_reload),
+ ('Python/<separator>', None, None),
+ ('Python/Run...', None, self.python_run),
+ ('Python/Debug...', None, self.python_debug),
+ ('Python/Profile...', None, self.python_prof),
+ ('Help/About...', None, self.help_about),
+ ])
+ self.add_accel_group(mf.accelerator)
+ hdlbox.add(mf)
+ mf.show()
+ self.mf = mf
+ self.interp = gtkcons.Console(
+ namespace={'__builtins__': __builtins__,
+ '__name__': '__main__',
+ '__doc__': None}, quit_cb=self.quit)
+ self.main_box.pack_start(self.interp)
+ self.interp.show()
+ self.interp.init()
+ self.editwins = []
+ def quit(self, *args):
+ for win in self.editwins:
+ if win.chk_save(): return
+ win.hide()
+ win.destroy()
+ mainquit()
+
+ def reload_file(self, fname):
+ if not os.path.isfile(fname):
+ GtkExtra.message_box("File Not Found", fname +
+ " was not found.", ("OK",))
+ dir = os.path.dirname(fname)
+ base = os.path.basename(fname)
+ if dir not in sys.path: sys.path.insert(0, dir)
+ if string.lower(base[-3:]) == '.py': base = base[:-3]
+ elif string.lower(base[-4:]) == '.pyc': base = base[:-4]
+ if not sys.modules.has_key(base):
+ self.interp.run('import ' + base)
+ else:
+ self.interp.run('import ' + base)
+ self.interp.run('reload(' + base + ')')
+
+ # execute a python script normally or with the debugger or profiler
+ def run_script(self, fname):
+ if not fname or os.path.exists(fname):
+ GtkExtra.message_box("Run","Invalid filename",("OK",))
+ return
+ args = GtkExtra.input_box("Arguments",
+ "Enter any command line arguments")
+ if args == None: return
+ os.system(VT_CMD+'python "'+fname+'" ' + args + ' &')
+ def debug_script(self, fname):
+ if not fname or os.path.exists(fname):
+ GtkExtra.message_box("Debug", "Invalid filename",
+ ("OK",))
+ return
+ args = GtkExtra.input_box("Arguments",
+ "Enter any command line arguments")
+ if args == None: return
+ os.system(VT_CMD+'python '+gtkdb.__file__+' "'+fname+'" ' +
+ args + ' &')
+ def profile_script(self, fname):
+ if not fname or not os.ppath.exists(fname):
+ GtkExtra.message_box("Profile", "Invalid filename",
+ ("OK",))
+ return
+ args = GtkExtra.input_box("Arguments",
+ "Enter any command line arguments")
+ if args == None: return
+ os.system(VT_CMD+'python '+gtkprof.__file__+' "'+fname+'" ' +
+ args + ' &')
+
+ def add_py_menu(self, ew):
+ def run(b=None, ew=ew, app=self): app.run_script(ew.fname)
+ def dbg(b=None, ew=ew, app=self): app.debug_script(ew.fname)
+ def prf(b=None, ew=ew, app=self): app.profile_script(ew.fname)
+ py_menu = GtkExtra.MenuFactory(MENU_FACTORY_MENU)
+ py_menu.add_entries([
+ ('Run...', None, run),
+ ('Debug...', None, dbg),
+ ('Profile...', None, prf)
+ ])
+ mi = GtkMenuItem('Python')
+ ew.mf.insert(mi, 2)
+ mi.show()
+ mi.set_submenu(py_menu)
+ ew.mf.hide()
+ ew.mf.show()
+
+ def file_new(self, mi=None):
+ ew = edit.EditWindow(quit_cb=self.rem_editwin)
+ self.editwins.append(ew)
+ self.add_py_menu(ew)
+ ew.show()
+ ew.set_usize(0,0)
+ def file_open(self, mi=None):
+ fname = GtkExtra.file_open_box(modal=FALSE)
+ if fname:
+ ew = edit.EditWindow(quit_cb=self.rem_editwin)
+ ew.load_file(fname)
+ self.editwins.append(ew)
+ self.add_py_menu(ew)
+ ew.show()
+ ew.set_usize(0,0)
+ def rem_editwin(self, win=None, event=None):
+ for i in range(len(self.editwins)):
+ if self.editwins[i] == win:
+ del self.editwins[i]
+ break
+ def file_exit(self, mi=None):
+ self.quit()
+ def edit_copy(self, mi=None):
+ self.interp.text.copy_clipboard(0)
+ def edit_paste(self, mi=None):
+ self.interp.line.paste_clipboard(0)
+ def edit_clear(self, mi=None):
+ self.interp.line.delete_selection()
+ def python_reload(self, mi=None):
+ print "python_reload"
+ def python_run(self, mi=None):
+ fname = GtkExtra.file_sel_box("Run")
+ if fname:
+ self.run_script(fname)
+ def python_debug(self, mi=None):
+ fname = GtkExtra.file_sel_box("Debug")
+ if fname:
+ self.debug_script(fname)
+ def python_prof(self, mi=None):
+ fname = GtkExtra.file_sel_box("Profile")
+ if fname:
+ self.profile_script(fname)
+ def help_about(self, mi=None):
+ print "help_about"
+
+if __name__ == '__main__':
+ app = Application()
+ app.show()
+ app.set_usize(0,0)
+ mainloop()
diff --git a/examples/ide/quit.xpm b/examples/ide/quit.xpm
new file mode 100644
index 00000000..11d0bb01
--- /dev/null
+++ b/examples/ide/quit.xpm
@@ -0,0 +1,36 @@
+/* XPM */
+static char *quit[] = {
+/* width height num_colors chars_per_pixel */
+" 20 22 6 1",
+/* colors */
+". c #ffcc33",
+"# c None",
+"a c #996600",
+"b c #666666",
+"c c #333333",
+"d c #000000",
+/* pixels */
+"####################",
+"####################",
+"####################",
+"########d####d######",
+"#######dad##dd###dd#",
+"#######d.addaad#dad#",
+"######da......dda.d#",
+"#dddddd..........ad#",
+"da...............dc#",
+"cda..............dc#",
+"#cd..............ad#",
+"##d...............ad",
+"#da.............addc",
+"#d.............ddcc#",
+"da.............dc###",
+"dddd...........ad###",
+"#ccd........adaad###",
+"###d..da....dcddd###",
+"###dbdcda...c#ccc###",
+"###cdc#ccdadc#######",
+"####c###ccdc########",
+"##########c#########"
+};
+
diff --git a/examples/ide/return.xpm b/examples/ide/return.xpm
new file mode 100644
index 00000000..a908f597
--- /dev/null
+++ b/examples/ide/return.xpm
@@ -0,0 +1,35 @@
+/* XPM */
+static char *return[] = {
+/* width height num_colors chars_per_pixel */
+" 20 22 5 1",
+/* colors */
+". c None",
+"# c #999999",
+"a c #666666",
+"b c #333333",
+"c c #000000",
+/* pixels */
+"....................",
+"..............c.....",
+"..............cc....",
+".........#bcccccc...",
+".....#bccccccccccc..",
+"..#bccccccccccccccc.",
+".acccccccccccccccccc",
+"#cccccccccccccccccc.",
+"bccccccccccccccccc..",
+"ccccccccccccccccc...",
+"cccccccccb#...cc....",
+"ccccccb#......c.....",
+"cccb#..b............",
+"cc..bbbbbb..........",
+"c.bbbbbbbb.a........",
+"bbbbbbbbbbb#........",
+".bbbbbbbbb.a........",
+"..bbbbbbbbb#........",
+"...bbbbbbb.a........",
+".....bbbbbb#........",
+"........bb.a........",
+"...................."
+};
+
diff --git a/examples/ide/run.xpm b/examples/ide/run.xpm
new file mode 100644
index 00000000..fbfb4ed8
--- /dev/null
+++ b/examples/ide/run.xpm
@@ -0,0 +1,28 @@
+/* XPM */
+static char * run_xpm[] = {
+"20 22 3 1",
+" c None",
+". c #000000",
+"X c #C00080",
+" ",
+" ",
+" .... ",
+" .XXXX. ",
+" .XXXX. ",
+" .XXXX. ",
+" .XXXX. ",
+" .XX. ",
+" .XX. ",
+" .XX. ",
+" .XX. ",
+" .. ",
+" .. ",
+" .. ",
+" .. ",
+" ",
+" .. ",
+" .XX. ",
+" .XX. ",
+" .. ",
+" ",
+" "};
diff --git a/examples/ide/step.xpm b/examples/ide/step.xpm
new file mode 100644
index 00000000..4e5c7bb3
--- /dev/null
+++ b/examples/ide/step.xpm
@@ -0,0 +1,35 @@
+/* XPM */
+static char *forward[] = {
+/* width height num_colors chars_per_pixel */
+" 20 22 5 1",
+/* colors */
+". c None",
+"# c #999999",
+"a c #666666",
+"b c #333333",
+"c c #000000",
+/* pixels */
+"....................",
+"........bb.a........",
+".....bbbbbb#........",
+"...bbbbbbb.a........",
+"..bbbbbbbbb#........",
+".bbbbbbbbb.a........",
+"bbbbbbbbbbb#........",
+"c.bbbbbbbb.a........",
+"cc..bbbbbb..........",
+"cccb#..b............",
+"ccccccb#......c.....",
+"cccccccccb#...cc....",
+"ccccccccccccccccc...",
+"bccccccccccccccccc..",
+"#cccccccccccccccccc.",
+".acccccccccccccccccc",
+"..#bccccccccccccccc.",
+".....#bccccccccccc..",
+".........#bcccccc...",
+"..............cc....",
+"..............c.....",
+"...................."
+};
+
diff --git a/examples/imlib/.cvsignore b/examples/imlib/.cvsignore
new file mode 100644
index 00000000..c2831020
--- /dev/null
+++ b/examples/imlib/.cvsignore
@@ -0,0 +1,6 @@
+Makefile.in
+Makefile
+*~
+*.pyc
+*.pyo
+
diff --git a/examples/imlib/view.py b/examples/imlib/view.py
new file mode 100755
index 00000000..9817a1f4
--- /dev/null
+++ b/examples/imlib/view.py
@@ -0,0 +1,52 @@
+#!/usr/bin/env python
+
+from gtk import *
+import GdkImlib
+
+def close(win, _event=None):
+ win.hide()
+ win.destroy()
+
+def resize(win, event):
+ im = win.get_data('user_data')
+ # note that render must be called once before each call to make_pixmap
+ im.render(event.width, event.height)
+ pix = win.children()[0]
+ win.remove(pix)
+ pix = im.make_pixmap()
+ pix.show()
+ win.add(pix)
+
+def open_img(_b):
+ file = fs.get_filename()
+ try:
+ im = GdkImlib.Image(file)
+ except RuntimeError: return
+ win = GtkWindow()
+ win.connect('destroy', close)
+ win.connect('delete_event', close)
+ win.connect('configure_event', resize)
+ win.set_title(file)
+ win.set_data('user_data', im)
+ im.render()
+ pix = im.make_pixmap()
+ pix.show()
+ win.add(pix)
+ win.show()
+
+fs = GtkFileSelection()
+fs.set_title('Image Viewer')
+fs.connect('destroy', mainquit)
+fs.connect('delete_event', mainquit)
+
+label = fs.ok_button.children()[0]
+label.set('View')
+fs.ok_button.connect('clicked', open_img)
+
+label = fs.cancel_button.children()[0]
+label.set('Quit')
+fs.cancel_button.connect('clicked', mainquit)
+
+fs.show()
+
+mainloop()
diff --git a/examples/neil/.cvsignore b/examples/neil/.cvsignore
new file mode 100644
index 00000000..c2831020
--- /dev/null
+++ b/examples/neil/.cvsignore
@@ -0,0 +1,6 @@
+Makefile.in
+Makefile
+*~
+*.pyc
+*.pyo
+
diff --git a/examples/neil/README b/examples/neil/README
new file mode 100644
index 00000000..071e73a6
--- /dev/null
+++ b/examples/neil/README
@@ -0,0 +1,4 @@
+The examples in this directory were originally sent in by Neil Schemenauer
+<nascheme@acs.ucalgary.ca>, but have since had small modifications and
+additions made by me (such as change over to using GtkItemFactory).
+
diff --git a/examples/neil/TAppli.py b/examples/neil/TAppli.py
new file mode 100755
index 00000000..1ab9e771
--- /dev/null
+++ b/examples/neil/TAppli.py
@@ -0,0 +1,142 @@
+#!/usr/bin/env python
+#
+# Test the GtkMenuBar, GtkMenu and GtkMenuItem, GtkList and
+# GtkListItem, GtkFileSelection objects
+#
+
+import sys
+import time
+from gtk import *
+
+class Application:
+ def __init__(self, argv):
+ self.w_window=GtkWindow()
+ self.w_window.set_title("Test application")
+ self.w_window.border_width(10)
+ self.w_vbox=GtkVBox()
+
+ self.init_menu()
+ self.init_list()
+ self.init_button()
+
+ self.w_window.add(self.w_vbox)
+ self.w_vbox.show()
+ self.w_window.show()
+
+ self.idlecount=0
+ idle_add(self.idle)
+
+ def mainloop(self):
+ mainloop()
+
+ def quit(self, mi):
+ mainquit()
+
+ def doit(self, button):
+ z=[]
+ for x in range(10,20):
+ item=GtkListItem(label="line %d" % x)
+ item.show()
+ z.append(item)
+ self.w_listbox.append_items(z)
+
+
+ def init_menu(self):
+ ag = GtkAccelGroup()
+ itemf = GtkItemFactory(GtkMenuBar, "<main>", ag)
+ self.w_window.add_accel_group(ag)
+ file_cb = self.process_file
+ edit_cb = self.process_edit
+ itemf.create_items([
+ ('/_File', None, None, 0, '<Branch>'),
+ ('/_File/_New', '<control>N', file_cb, 1, ''),
+ ('/_File/_Open', '<control>O', file_cb, 2, ''),
+ ('/_File/_Save', '<control>S', file_cb, 3, ''),
+ ('/_File/Save _As', None, file_cb, 4, ''),
+ ('/_File/_Close', None, file_cb, 5, ''),
+ ('/_File/sep1', None, file_cb, 0, '<Separator>'),
+ ('/_File/E_xit', '<alt>F4', file_cb, 6, ''),
+ ('/_Edit', None, None, 0, '<Branch>'),
+ ('/_Edit/C_ut', '<control>X', edit_cb, 1, ''),
+ ('/_Edit/_Copy', '<control>C', edit_cb, 2, ''),
+ ('/_Edit/_Paste', '<control>V', edit_cb, 3, '')
+ ])
+ self.w_menubar = itemf.get_widget('<main>')
+ self.w_vbox.pack_start(self.w_menubar, expand=FALSE)
+ self.w_menubar.show()
+
+ def init_list(self):
+ c=GtkScrolledWindow()
+ c.set_usize(250,200)
+ self.w_listbox=GtkList()
+ self.w_listbox.set_selection_mode(SELECTION_MULTIPLE)
+ c.add(self.w_listbox)
+ self.w_vbox.pack_start(c)
+
+ for x in range(0,10):
+ item=GtkListItem(label="line %d" % x)
+ item.show()
+ self.w_listbox.add(item)
+ self.w_listbox.show()
+ c.show()
+
+ def init_button(self):
+ t = GtkTable(rows=1, cols=2, homogeneous=TRUE)
+ b1 = GtkButton('Do it!')
+ b1.connect('clicked', self.doit)
+ b2 = GtkButton('Quit')
+ b2.connect('clicked', self.quit)
+ t.attach(b1, 0, 1, 0, 1, yoptions=0, xpadding=2, ypadding=2)
+ t.attach(b2, 1, 2, 0, 1, yoptions=0, xpadding=2, ypadding=2)
+
+ self.w_vbox.pack_end(t, expand=FALSE)
+
+ b1.show()
+ b2.show()
+ t.show()
+
+ def process_file(self, action, widget):
+ if action == 0: print "unknown"
+ elif action == 1: print "File:New"
+ elif action == 2: print "File:Open"
+ elif action == 3: print "File:Save"
+ elif action == 4: print "File:Save As"
+ elif action == 5: print "File:Close"
+ elif action == 6:
+ print "File:Exit"
+ mainquit()
+ def process_edit(self, action, widget):
+ if action == 0: print "Edit:<unknown>"
+ elif action == 1: print "Edit:Cut"
+ elif action == 2: print "Edit:Copy"
+ elif action == 3: print "Edit:Paste"
+
+ def idle(self):
+ self.idlecount = self.idlecount + 1
+ if(self.idlecount % 1000 == 0):
+ print "Idle:", self.idlecount
+ # if measuring time
+ ##self.quit()
+ return TRUE
+
+
+if(__name__=="__main__"):
+ use_defaults=1
+ for arg in sys.argv:
+ if(arg=="-d"):
+ import pdb
+ pdb.set_trace()
+
+ if(arg=="-n"):
+ use_defaults=0
+
+ start_time = time.time()
+
+# if(use_defaults==1):
+# gtk.rc_parse("defaults.rc")
+
+ app=Application(sys.argv)
+ app.mainloop()
+ the_time = time.time() - start_time
+ print "Application ran %.2f s." % the_time
+
diff --git a/examples/neil/TAppli2.py b/examples/neil/TAppli2.py
new file mode 100755
index 00000000..5fa56d84
--- /dev/null
+++ b/examples/neil/TAppli2.py
@@ -0,0 +1,129 @@
+#!/usr/bin/env python
+#
+# Test of gtk.Text widget.
+#
+
+import sys
+import time
+from gtk import *
+import GtkExtra
+
+class Application:
+ def __init__(self, argv):
+ self.w_window=GtkWindow()
+ self.w_window.set_title("Test application")
+ self.w_window.border_width(10)
+ self.w_vbox=GtkVBox()
+
+ self.init_menu()
+ self.init_text()
+
+ self.w_window.add(self.w_vbox)
+ self.w_vbox.show()
+ self.w_window.show()
+
+ def mainloop(self):
+ mainloop()
+
+ def init_menu(self):
+ ag = GtkAccelGroup()
+ itemf = GtkItemFactory(GtkMenuBar, "<main>", ag)
+ self.w_window.add_accel_group(ag)
+ file_cb = self.process_file
+ edit_cb = self.process_edit
+ itemf.create_items([
+ ('/_File', None, None, 0, '<Branch>'),
+ ('/_File/_New', '<control>N', file_cb, 1, ''),
+ ('/_File/_Open', '<control>O', file_cb, 2, ''),
+ ('/_File/_Save', '<control>S', file_cb, 3, ''),
+ ('/_File/Save _As', None, file_cb, 4, ''),
+ ('/_File/_Close', None, file_cb, 5, ''),
+ ('/_File/sep1', None, file_cb, 0, '<Separator>'),
+ ('/_File/E_xit', '<alt>F4', file_cb, 6, ''),
+ ('/_Edit', None, None, 0, '<Branch>'),
+ ('/_Edit/C_ut', '<control>X', edit_cb, 1, ''),
+ ('/_Edit/_Copy', '<control>C', edit_cb, 2, ''),
+ ('/_Edit/_Paste', '<control>V', edit_cb, 3, '')
+ ])
+ self.w_menubar = itemf.get_widget('<main>')
+ self.w_vbox.pack_start(self.w_menubar, expand=FALSE)
+ self.w_menubar.show()
+
+ def init_text(self):
+ self.w_table=GtkTable(2,2,0)
+ self.w_table.show()
+
+ self.w_text=GtkText()
+ self.w_text.set_usize(350,250)
+ ## Note: editable text is disable in gtk+-971109
+ self.w_text.set_editable(0)
+ self.w_table.attach(self.w_text,0,1,0,1,xpadding=1,ypadding=1)
+ self.w_text.show()
+
+ self.w_hscrollbar=GtkHScrollbar(self.w_text.get_hadjustment())
+ self.w_table.attach(self.w_hscrollbar,0,1,1,2,yoptions=FILL)
+ self.w_hscrollbar.show()
+
+ self.w_vscrollbar=GtkVScrollbar(self.w_text.get_vadjustment())
+ self.w_table.attach(self.w_vscrollbar,1,2,0,1,xoptions=FILL)
+ self.w_vscrollbar.show()
+
+ self.w_vbox.pack_start(self.w_table)
+
+ def process_file(self, action, widget):
+ if action == 0: print "File:<unknown>"
+ elif action == 1:
+ print "File:New"
+ self.w_text.freeze()
+ self.w_text.set_point(0)
+ self.w_text.forward_delete(self.w_text.get_length())
+ self.w_text.insert_defaults("Hello")
+ self.w_text.thaw()
+ #self.w_text.queueDraw()
+ elif action == 2:
+ print "File:Open"
+ fname = GtkExtra.file_open_box(modal=FALSE)
+ if fname:
+ try:
+ f=open(fname, "r")
+ except IOError:
+ return
+ self.w_text.freeze()
+ while TRUE:
+ line = f.readline()
+ if line == "":
+ break
+ self.w_text.insert_defaults(line)
+ self.w_text.thaw()
+ elif action == 3:
+ print "File:Save"
+ elif action == 4:
+ print "File:Save As"
+ print GtkExtra.file_save_box(modal=FALSE), "chosen"
+ elif action == 5:
+ print "File:Close"
+ elif action == 6:
+ print "File:Exit"
+ mainquit()
+ def process_edit(self, action, widget):
+ if action == 0: print "Edit:<unknown>"
+ elif action == 1: print "Edit:Cut"
+ elif action == 2: print "Edit:Copy"
+ elif action == 3: print "Edit:Paste"
+
+if __name__ == "__main__":
+ use_defaults=0
+ for arg in sys.argv:
+ if arg == "-d":
+ import pdb
+ pdb.set_trace()
+
+ if arg == "-n":
+ use_defaults=0
+
+ if use_defaults == 1:
+ gtk.rc_parse("defaults.rc")
+
+ app=Application(sys.argv)
+ app.mainloop()
+
diff --git a/examples/neil/TAppli3.py b/examples/neil/TAppli3.py
new file mode 100755
index 00000000..08433448
--- /dev/null
+++ b/examples/neil/TAppli3.py
@@ -0,0 +1,141 @@
+#!/usr/bin/env python
+#
+# Tests of pygtk
+#
+
+import sys
+from gtk import *
+import GtkExtra
+
+class Application:
+ def __init__(self, argv):
+ self.w_window=GtkWindow(title="Test Application")
+ self.w_window.border_width(10)
+ self.w_vbox=GtkVBox()
+
+ self.init_menu()
+ self.init_text()
+
+ self.w_window.add(self.w_vbox)
+ self.w_vbox.show()
+ self.w_window.show()
+
+ def mainloop(self):
+ mainloop()
+
+ def init_menu(self):
+ ag = GtkAccelGroup()
+ itemf = GtkItemFactory(GtkMenuBar, "<main>", ag)
+ self.w_window.add_accel_group(ag)
+ file_cb = self.process_file
+ edit_cb = self.process_edit
+ itemf.create_items([
+ ('/_File', None, None, 0, '<Branch>'),
+ ('/_File/_New', '<control>N', file_cb, 1, ''),
+ ('/_File/_Open', '<control>O', file_cb, 2, ''),
+ ('/_File/_Save', '<control>S', file_cb, 3, ''),
+ ('/_File/Save _As', None, file_cb, 4, ''),
+ ('/_File/_Close', None, file_cb, 5, ''),
+ ('/_File/sep1', None, file_cb, 0, '<Separator>'),
+ ('/_File/E_xit', '<alt>F4', file_cb, 6, ''),
+ ('/_Edit', None, None, 0, '<Branch>'),
+ ('/_Edit/C_ut', '<control>X', edit_cb, 1, ''),
+ ('/_Edit/_Copy', '<control>C', edit_cb, 2, ''),
+ ('/_Edit/_Paste', '<control>V', edit_cb, 3, '')
+ ])
+ self.w_menubar = itemf.get_widget('<main>')
+ self.w_vbox.pack_start(self.w_menubar, expand=FALSE)
+ self.w_menubar.show()
+
+ def init_text(self):
+ self.w_table=GtkTable(2,2,0)
+ self.w_table.show()
+
+ self.w_text=GtkText()
+ self.w_text.set_usize(350,250)
+ ## Note: editable text is disable in gtk+-971109
+ self.w_text.set_editable(1)
+ self.w_table.attach(self.w_text,0,1,0,1,xpadding=1,ypadding=1)
+ self.w_text.show()
+
+ self.w_hscrollbar=GtkHScrollbar(self.w_text.get_hadjustment())
+ self.w_table.attach(self.w_hscrollbar,0,1,1,2,yoptions=FILL)
+ self.w_hscrollbar.show()
+
+ self.w_vscrollbar=GtkVScrollbar(self.w_text.get_vadjustment())
+ self.w_table.attach(self.w_vscrollbar,1,2,0,1,xoptions=FILL)
+ self.w_vscrollbar.show()
+
+ self.w_vbox.pack_start(self.w_table)
+
+ def process_file(self, action, widget):
+ if action == 0: print "File:<unknown>"
+ elif action == 1:
+ print "File:New"
+ self.w_text.freeze()
+ self.w_text.set_point(0)
+ self.w_text.insert_defaults("*new file*")
+ self.w_text.thaw()
+ #self.w_text.queueDraw()
+ elif action == 2:
+ print "File:Open"
+ fname = GtkExtra.file_open_box(modal=FALSE)
+ if fname:
+ try:
+ f=open(fname, "r")
+ except IOError:
+ return
+ self.w_text.freeze()
+ while TRUE:
+ line = f.readline()
+ if line == "":
+ break
+ self.w_text.insert_defaults(line)
+ self.w_text.thaw()
+ elif action == 3:
+ print "File:Save"
+ GtkExtra.message_box("Test Application",
+ "Not implemented",
+ pixmap='bomb.xpm')
+ elif action == 4:
+ print "File:Save As"
+ print GtkExtra.file_save_box(modal=FALSE), "chosen"
+ elif action == 5:
+ print "File:Close"
+ elif action == 6:
+ print "File:Exit"
+ mainquit()
+
+ def process_edit(self, action, widget):
+ if action == 0: print "Edit:<unknown>"
+ elif action == 1:
+ print "Edit:Cut"
+ self.w_text.cut_clipboard(0)
+ elif action == 2:
+ print "Edit:Copy"
+ self.w_text.copy_clipboard(0)
+ elif action == 3:
+ print "Edit:Paste"
+ self.w_text.paste_clipboard(0)
+
+ def process_character(self, *args):
+ print "process_character"
+ def process_button(self, *args):
+ print "process_button"
+
+if(__name__=="__main__"):
+ use_defaults=1
+ for arg in sys.argv:
+ if(arg=="-d"):
+ import pdb
+ pdb.set_trace()
+
+ if(arg=="-n"):
+ use_defaults=0
+
+# if(use_defaults==1):
+# Gtkrc_parse("defaults.rc")
+
+ app=Application(sys.argv)
+ app.mainloop()
+
diff --git a/examples/neil/TAppli4.py b/examples/neil/TAppli4.py
new file mode 100755
index 00000000..0c45a653
--- /dev/null
+++ b/examples/neil/TAppli4.py
@@ -0,0 +1,126 @@
+#!/usr/bin/env python
+#
+# Tests of python-Gtk
+#
+
+import sys
+from gtk import *
+import GtkExtra
+
+class Application:
+ def __init__(self, argv):
+ self.w_window=GtkWindow(title="Test Application")
+ self.w_window.border_width(10)
+ self.w_vbox=GtkVBox()
+
+ self.init_menu()
+ self.init_canvas()
+
+ self.w_window.add(self.w_vbox)
+ self.w_vbox.show()
+ self.w_window.show()
+
+ def mainloop(self):
+ mainloop()
+
+ def init_menu(self):
+ ag = GtkAccelGroup()
+ itemf = GtkItemFactory(GtkMenuBar, "<main>", ag)
+ self.w_window.add_accel_group(ag)
+ file_cb = self.process_file
+ edit_cb = self.process_edit
+ help_cb = self.process_help
+ itemf.create_items([
+ ('/_File', None, None, 0, '<Branch>'),
+ ('/_File/_New', '<control>N', file_cb, 1, ''),
+ ('/_File/_Open', '<control>O', file_cb, 2, ''),
+ ('/_File/_Save', '<control>S', file_cb, 3, ''),
+ ('/_File/Save _As', None, file_cb, 4, ''),
+ ('/_File/_Close', None, file_cb, 5, ''),
+ ('/_File/sep1', None, file_cb, 0, '<Separator>'),
+ ('/_File/E_xit', '<alt>F4', file_cb, 6, ''),
+ ('/_Edit', None, None, 0, '<Branch>'),
+ ('/_Edit/C_ut', '<control>X', edit_cb, 1, ''),
+ ('/_Edit/_Copy', '<control>C', edit_cb, 2, ''),
+ ('/_Edit/_Paste', '<control>V', edit_cb, 3, ''),
+ ('/_Help', None, None, 0, '<LastBranch>'),
+ ('/_Help/_About', '<control>A', help_cb, 1, '')
+ ])
+ self.w_menubar = itemf.get_widget('<main>')
+ self.w_vbox.pack_start(self.w_menubar, expand=FALSE)
+ self.w_menubar.show()
+
+ def init_canvas(self):
+ self.w_canvas=GtkDrawingArea()
+ self.w_canvas.size(350,250)
+ self.w_canvas.show()
+ self.w_vbox.pack_start(self.w_canvas)
+
+ self.w_canvas.connect("button_press_event", self.process_button)
+ self.w_canvas.connect("motion_notify_event", self.process_motion)
+ self.w_canvas.connect("key_press_event", self.process_key)
+ self.w_canvas.set_events(GDK.BUTTON_PRESS_MASK |
+ GDK.POINTER_MOTION_MASK |
+ GDK.POINTER_MOTION_HINT_MASK |
+ GDK.KEY_PRESS_MASK)
+
+ def process_file(self, action, widget):
+ if action == 0: print "File:<unknwon>"
+ elif action == 1:
+ print "File:New"
+ elif action == 2:
+ print "File:Open"
+ print GtkExtra.file_open_box(modal=FALSE), "chosen"
+ elif action == 3:
+ print "FileSave"
+ dlg=GtkExtra.message_box("Test Application",
+ "Not implemented",
+ ("OK",), pixmap='bomb.xpm')
+ elif action == 4:
+ print "File:Save As"
+ print GtkExtra.file_save_box(modal=FALSE), "chosen"
+ elif action == 5:
+ print "File:Close"
+ elif action == 6:
+ print "File:Exit"
+ mainquit()
+ def process_edit(self, action, widget):
+ if action == 0: print "Edit:<unknown>"
+ elif action == 1: print "Edit:Cut"
+ elif action == 2: print "Edit:Copy"
+ elif action == 3: print "Edit:Paste"
+
+ def process_help(self, action, widget):
+ dlg=GtkExtra.message_box("Test Application",
+ "Test Application for Python-Gtk.\n" +
+ "This is free software.\n" +
+ "This application tests mouse and " +
+ "key press events.", ("OK",),
+ pixmap='question.xpm')
+
+ def process_button(self, win, event):
+ print event, "b =", event.button, "x =", event.x, "y =", event.y
+
+ def process_motion(self, win, event):
+ print event, "is_hint =", event.is_hint, "x =", event.x, "y =", event.y
+
+ def process_key(self, win, event):
+ print event, "keyval =", event.keyval, "state =", event.state
+
+
+if(__name__=="__main__"):
+ use_defaults=1
+ for arg in sys.argv:
+ if(arg=="-d"):
+ import pdb
+ pdb.set_trace()
+
+ if(arg=="-n"):
+ use_defaults=0
+
+# if(use_defaults==1):
+# rc_parse("defaults.rc")
+
+ app=Application(sys.argv)
+ app.mainloop()
+
diff --git a/examples/neil/TAppli5.py b/examples/neil/TAppli5.py
new file mode 100755
index 00000000..1402e2a9
--- /dev/null
+++ b/examples/neil/TAppli5.py
@@ -0,0 +1,188 @@
+#!/usr/bin/env python
+#
+# Tests of python-gtk.
+#
+
+import sys
+from gtk import *
+import GtkExtra
+
+class Application:
+ def __init__(self, argv):
+
+ # hardcoded font - maybe not on every server ?
+ self.medium_fonts= [
+ "lucidasanstypewriter-10",
+ "lucidasanstypewriter-12",
+ "lucidasanstypewriter-14",
+ "lucidasanstypewriter-18",
+ "lucidasanstypewriter-24"
+ ]
+ self.bold_fonts= [
+ "lucidasanstypewriter-bold-10",
+ "lucidasanstypewriter-bold-12",
+ "lucidasanstypewriter-bold-14",
+ "lucidasanstypewriter-bold-18",
+ "lucidasanstypewriter-bold-24"
+ ]
+ self.font_type=0
+ self.font_index=0
+ # dictionary of loaded fonts
+ self.fonts={}
+
+ self.w_window=GtkWindow()
+ self.w_window.set_title("Test application")
+ self.w_window.border_width(10)
+ self.w_vbox=GtkVBox()
+
+ self.init_menu()
+ self.init_text()
+
+ self.w_window.add(self.w_vbox)
+ self.w_vbox.show()
+ self.w_window.show()
+
+ def mainloop(self):
+ mainloop()
+
+ def init_menu(self):
+ ag = GtkAccelGroup()
+ itemf = GtkItemFactory(GtkMenuBar, "<main>", ag)
+ self.w_window.add_accel_group(ag)
+ file_cb = self.process_file
+ edit_cb = self.process_edit
+ help_cb = self.process_help
+ itemf.create_items([
+ ('/_File', None, None, 0, '<Branch>'),
+ ('/_File/_New', '<control>N', file_cb, 1, ''),
+ ('/_File/_Open', '<control>O', file_cb, 2, ''),
+ ('/_File/_Save', '<control>S', file_cb, 3, ''),
+ ('/_File/Save _As', None, file_cb, 4, ''),
+ ('/_File/_Close', None, file_cb, 5, ''),
+ ('/_File/sep1', None, file_cb, 0, '<Separator>'),
+ ('/_File/E_xit', '<alt>F4', file_cb, 6, ''),
+ ('/_Edit', None, None, 0, '<Branch>'),
+ ('/_Edit/C_ut', '<control>X', edit_cb, 1, ''),
+ ('/_Edit/_Copy', '<control>C', edit_cb, 2, ''),
+ ('/_Edit/_Paste', '<control>V', edit_cb, 3, ''),
+ ('/_Help', None, None, 0, '<LastBranch>'),
+ ('/_Help/_About', '<control>A', help_cb, 1, '')
+ ])
+ self.w_menubar = itemf.get_widget('<main>')
+ self.w_vbox.pack_start(self.w_menubar, expand=FALSE)
+ self.w_menubar.show()
+
+ def init_text(self):
+ self.w_table=GtkTable(2,2,0)
+ self.w_table.show()
+
+ self.w_text=GtkText()
+ self.w_text.set_usize(350,250)
+ ## Note: editable text is disable in gtk+-971109
+ self.w_text.set_editable(0)
+ self.w_table.attach(self.w_text,0,1,0,1,xpadding=1,ypadding=1)
+ self.w_text.show()
+
+ self.w_text.connect("key_press_event", self.process_key)
+ self.w_text.set_events(GDK.KEY_PRESS_MASK)
+
+ self.w_hscrollbar=GtkHScrollbar(self.w_text.get_hadjustment())
+ self.w_table.attach(self.w_hscrollbar,0,1,1,2,
+ yoptions=FILL)
+ self.w_hscrollbar.show()
+
+ self.w_vscrollbar=GtkVScrollbar(self.w_text.get_vadjustment())
+ self.w_table.attach(self.w_vscrollbar,1,2,0,1,
+ xoptions=FILL)
+ self.w_vscrollbar.show()
+
+ self.w_vbox.pack_start(self.w_table)
+
+ def process_file(self, action, widget):
+ if action == 0: print "File:<unknown>"
+ elif action == 1:
+ print "File:New"
+ self.w_text.freeze()
+ self.w_text.set_point(0)
+ self.w_text.insert_defaults("*new file*")
+ self.w_text.thaw()
+ #self.w_text.queueDraw()
+ elif action == 2:
+ print "File:Open"
+ print GtkExtra.file_open_box(modal=FALSE), "chosen"
+ elif action == 3:
+ print "File:Save"
+ GtkExtra.message_box("Test Application",
+ "Not Implemented",
+ ("OK",), pixmap='bomb.xpm')
+ elif action == 4:
+ print "File:Save As"
+ print GtkExtra.message_box(modal=FALSE), "chosen"
+ elif action == 5:
+ print "File:Close"
+ GtkExtra.message_box("Test Application",
+ "Not Implemented",
+ ("OK",), pixmap='bomb.xpm')
+ elif action == 6:
+ print "File:Exit"
+ mainquit()
+
+ def process_edit(self, action, widget):
+ if action == 0: print "Edit:<unknown>"
+ elif action == 1: print "Edit:Cut"
+ elif action == 2: print "Edit:Copy"
+ elif action == 3: print "Edit:Paste"
+
+ def process_help(self, action, widget):
+ GtkExtra.message_box("Test Application",
+ """Test Application for Python-Gtk.
+ This is free software.
+ This application tests key press events and text display.
+ Any entered key (printable character) is displayed on
+ screen. <F1> toggle medium and bold font. <F2> permits
+ to change font size.
+ """, ("OK",), pixmap='question.xpm')
+
+ def process_key(self, win, event):
+ if(event.keyval>=32 and event.keyval<=256):
+ if(self.font_type==0):
+ font=self.medium_fonts[self.font_index]
+ if(not self.fonts.has_key(font)):
+ self.fonts[font] = load_font(font)
+ f=self.fonts[font]
+ else:
+ font=self.bold_fonts[self.font_index]
+ if(not self.fonts.has_key(font)):
+ self.fonts[font] = load_font(font)
+ f=self.fonts[font]
+ self.w_text.freeze()
+ style = self.w_text.get_style()
+ self.w_text.insert(f, style.fg[STATE_NORMAL],
+ style.bg[STATE_NORMAL],
+ chr(event.keyval))
+ self.w_text.thaw()
+ else:
+ # hardcoded key interpretation... XXX need some python keysymdef ?
+ if(event.keyval==65470):
+ # this is F1
+ self.font_type = (self.font_type+1)%2
+ elif(event.keyval==65471):
+ # this is F2
+ self.font_index=(self.font_index+1)%len(self.medium_fonts)
+
+if(__name__=="__main__"):
+ use_defaults=0
+ for arg in sys.argv:
+ if(arg=="-d"):
+ import pdb
+ pdb.set_trace()
+
+ if(arg=="-n"):
+ use_defaults=0
+
+ if(use_defaults==1):
+ gtk.rc_parse("defaults.rc")
+
+ app=Application(sys.argv)
+ app.mainloop()
+
diff --git a/examples/neil/bomb.xpm b/examples/neil/bomb.xpm
new file mode 100644
index 00000000..a0af5157
--- /dev/null
+++ b/examples/neil/bomb.xpm
@@ -0,0 +1,47 @@
+/* XPM */
+static char * icl8_11432_xpm[] = {
+/* width height ncolors chars_per_pixel */
+"32 32 9 1",
+/* colors */
+" s None c None",
+"o c #999999",
+"O c black",
+"+ c #333333",
+"@ c #111111",
+"# c #FF6666",
+"$ c #FEFE00",
+"% c #DDDDDD",
+"& c #BBBBBB",
+/* pixels */
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" oOoOo ",
+" O Oo ",
+" o O ",
+" O o ",
+" +++++ O ",
+" +@@@+ o ",
+" +@@O@@+ O ",
+" ++@OOO@O@++ o # $",
+" +@@OOOOOOO@@+ O $ # ",
+" +@OOOOOOOOOOO@+ o $ ",
+" +@OOOOOO%&oOO@+ O # $ ",
+" +@OOOOOOOO%&oOO@+ o ",
+" +@OOOOOOOOOOOOO@+ OoO # $ #",
+" +@OOOOOOOOO%&oO@+ ",
+" +@OOOOOOOOO%&oO@+ $ $ ",
+" +@OOOOOOOOO%&oO@+ # # ",
+" +@OOOOOOOO%&oOO@+ # ",
+" +@OOOOOOOO%&oOO@+ $ $ $",
+" +@OOOOOO%&oOO@+ ",
+" +@OOOOOOOOOOO@+ # ",
+" +@@OOOOOOO@@+ ",
+" ++@@@@@@@++ ",
+" +++++++ ",
+" "};
diff --git a/examples/neil/gtk-logo.xpm b/examples/neil/gtk-logo.xpm
new file mode 100644
index 00000000..d0bc8c39
--- /dev/null
+++ b/examples/neil/gtk-logo.xpm
@@ -0,0 +1,162 @@
+/* XPM */
+static char *magick[] = {
+/* columns rows colors chars-per-pixel */
+"107 140 16 1",
+" c #06060a",
+". c #181922",
+"X c #32383c",
+"o c #3d73e1",
+"O c #3465cb",
+"+ c #334fa0",
+"@ c #3ce73c",
+"# c #34ce38",
+"$ c #31a535",
+"% c #f44e4c",
+"& c #ab323a",
+"* c #9668a4",
+"= c #fefefc",
+"- c #dce0e4",
+"; c #aeaabc",
+": c #648bc2",
+/* pixels */
+"===========================================================================================================",
+"===========================================================================================================",
+"===========================================================================================================",
+"===========================================================================================================",
+"===========================================================================================================",
+"===========================================================================================================",
+"===========================================================================================================",
+"===========================================================================================================",
+"===========================================================================================================",
+"=========================================================;-================================================",
+"================================================-*;=====;+O*.;=============================================",
+"==============================================-...-==;*++.X.X X;===========================================",
+"=============================================;X..+X+X+XXX... .-=========================================",
+"===========================================;+XXXXXXX...+.++.. X-=======================================",
+"=========================================-XX.XX.........O..oo.. .*======================================",
+"=======================================-*. XX. ........+.Ooooo+ . X-====================================",
+"======================================-X. .. . ........+OooooooO. X===================================",
+"====================================-:..... .. +.....Oooooooooooo+ .;=================================",
+"===================================-X .. ...+.....Oooooooooooooooo.. *================================",
+"==================================X ... ..OooooooooooooooooooX X===============================",
+"===============================-X.. . . ......O++ooooooooooooooooooo+. .-=============================",
+"==============================;.. . .....OOOoooooooooooooooooooooOO.. *============================",
+"============================-. .....+oOooooooooooooooooooooooooooOX. X-==========================",
+"==========================-+. ....+oooooooO++O++.+.++Oooooooooooooo+.. .;=========================",
+"=========================;. . ...+Oooo+. ............ ...OoooooooooooO... +========================",
+"=======================-X . . .+oOoO....+X+....... . ..+oooooooooO+.. ;======================",
+"======================: . . .OOOoo+....... . . ..OOooooooo++. X=====================",
+"====================-X ..+OooooX .. ..X . . . .. .XooooooOO+. .;===================",
+"===================;. . +Ooooo+. . . . .. . ..OooooooO+. X==================",
+"==================. .XOoooooO. . .XOOooOX++......... . Ooooooooo+X .-================",
+"================; . ...+ooooooO.. . ..ooooooooooOoo+..... . .oooooooooo+. *===============",
+"==============-$ .X++oooooooO. . ..+OooooooooooooooO...... ....OoooooooooooX .-=============",
+"=============;. .Oooooooooo+. . .. .OOOooooooooooooooooO .+X. .. +ooooooooooooO. *============",
+"====;======-. +oooooooooo+X. .X +oooooooooooooooooooO+.... ..ooooooooooooooX. .-==========",
+"====*=====* . .Oooooooooooo.... .+ Xooooooooooooooooooooooo+... ...ooooooooooooooo+ .;=========",
+"====X-==; .ooooooooooooO.+. ... ..OooooooooooooooooooooooOoo+. ..OooooooooooooooOo. .*========",
+"====X;--$. .OoooooooooooooO.O . .. .oooooooooooooooooooooooooo .. ..oooooooooooooooooo+ +=======",
+"====+X.-X ..+oooooooooooooooOO.+ . .OooooooooooooooOoOooooooooO+ ... .+oooooooooooooooooooo. :*====",
+"====;XX. ++OoooooooooooooooO..+ . .+ooooooooooooo++ ++OoooooooOooo+X.OoooooooooooooooooooooO X==-=",
+"====*X.. ..+oooooooooooooooO+. ..OoooooooooooOX. .+Ooooooooooooooooooooooooooooooooooooo::. X====",
+"====;X.. .&.X.X+Oooooooooooooooo+ .++oooooooooo+. ..XOoooooooooooooooooooooooooooooooooooO::X +-===",
+"===-;X. ..&%...X+Ooooooooooooooo+. . +OooooooooooO+ ....OoooooooooooooooooooooooooooooOO:XXX.XX.*====",
+"====-... .%%& .XOooooooooooooooo . .oooooooooooO.. . ..OOoooooooooooooooooooooooooooo+XX.XX#X *-===",
+"====-XX ..%%%&. .X+oooooooooooooo+ . +oooooooooo+. . .X+OoOoooooooooooooooooooooo:+..XX;@$ .;====",
+"====-. .%%%%& .+OooooooooooooO . OooooooooooX. ..+.+ooooooooooooooooooooO*X..X#@@@X -=-==",
+"====-XX ..%%%%%& .Xooooooooooooo. ... +oooooooOoO+. ...Xoooooooooooooooooo:XX...$@@@@@X .-====",
+"====-X.. .%%%%%%&. .X+oooooooooooo. ... .XoooooooooO+ ..+ooooooooooooooooooXX...X##@@@@@. .-====",
+"====-X....%%%%%%%%. XXOOoooooooooX .... ..ooooooooOo ..OOooooooooooooooO+X. X#@@@@@@@@. .;====",
+"=====X.. &&%%%%%%%%. .X+oooooooooo. ... ..+ooooooooX ..ooooooooooooooo+OX ..$#@@@@@@@@@. -====",
+"====-$.. .%%%%%%%%%%. ..+Ooooooooo+ .. .. . ..+OOo+. ..Oooooooooooooo++X. .$#@@@@@@@@@@. .-====",
+"=====X. &%%%%%%%%%%%. ..ooooooooo+ .. . .X. .+oooooooooooooXX.. .$#@@@@@@@@@@@# .=====",
+"=====.. %%%%%%%%%%%%& ... .oOooooooo. . ..Ooooooooooooo+X. .X#@@@@@@@@@@@@@$. X=====",
+"=====$. .%%%%%%%%%%%%%. .. ..XOoooooooO. . .++Oooooooooooo:X.. ..#@@@@@@@@@@@@@@@$ *-====",
+"=====X. ..%%%%%%%%%%%%%%&... ..X+ooooooooX. .+OOoooooooooOOX.. .$@@@@@@@@@@@@@@@@@. *=====",
+"=====X . .%%%%%%%%%%%%%%&...& .X+ooooooooooX.... .Oooooooooooo+.X. X@@@@@@@@@@@@@@@@@@@@. *-====",
+"====-X ..%%%%%%%%%%%%%%%%. &&. .XOooooooooooO+O+...+Ooooooooooo++... . $@@@@@@@@@@@@@@@@@@@@@. *=====",
+"=====$ .%%%%%%%%%%%%%%%%%.. &&. XOooooooooooooooooooooooooooOX. ... X#@@@@@@@@@@@@@@@@@@@@@@. ;=====",
+"=====X .%%%%%%%%%%%%%%%%%%...&&. +oooooooooooooooooooooooOX..... .X@@@@@@@@@@@@@@@@@@@@@@@@@. -=====",
+"====-X .%%%%%%%%%%%%%%%%%%%..&&%&. XooooooooooooooooooooO+..... . .$@@@@@@@@@@@@@@@@@@@@@@@@@# ;=====",
+"====-$. . %%%%%%%%%%%%%%%%%%%% .%%%& .Oooooooooooooooooo+....... .X@@@@@@@@@@@@@@@@@@@X.@@@@@#. *-====",
+"=====X .%%%%%%%%%%&&%%%%%%%%%. .%%%%X XOooooooooooooO++..XX.. .#@@@@@@@@@@@@@@@@@@@...@@@@@#. +-=====",
+"=====X . %%%%%%%%%X &%%%%%%%%%%. %%%%& +oooooooooo. . OX. $#@@@@@@@@@@@@@@@@#X$$..$@@@@@#. *======",
+"=====X. .&%%%%%%%%. ..&%%%%%%%%%. .&%%%%. .OooooooooX..X.. X$@@@@@@@@@@@@@@@@@$ .. .@@@@@@$ *-=====",
+"====-X. ..&%%%%%%%&. %%%%%%%%%.. &%%%%X. ..+ooooOOoX... $@@@@@@@@@@@@@@@@@@$ ....#@@@@@@$ .;======",
+"=====X & &%%%%%%%&. &%%%%%%%.. &%%%%X.. .+o+ooOX.. X##@@@@@@@@@@@@@@@@@#. $#@@@@@@$ ;======",
+"====-X. ...%%%%%%%X.. .&%%%%%%& &%%%%&... ..O+$X .$@@@@@@@@@@@@@@@@@@@@X .$@@@@@@@. .-======",
+"====-X & &%%%%%%&X.. &%%%%%%. .%%%&&.. ..$ .$@@@@@@@@@@@@@@@@@@@@$ X@@@@@@@@. .-======",
+"====-X &..%%%%%%&... .%%%%%%& ..%%%%&&.. ... X##@@@@@@@@@#@@@@@@@@@@@# . @@@@@@@@@. X=======",
+"====-X. ..&%%%%%%X... .. . .&&%%%%& .%%%%%.. .@@@#@@@@@@@@@#$..#@@@@@@@@@. $@@@@@@@@#. X=======",
+"====-X &. %%%%%%. ... %%%%%&. &%%%.. $@@@@@@@@@@$.... $@@@@@@@@@. .@@@@@@@@@# +=======",
+"====-X &..%%%%%%X. . . .%%%&&. &%%X. .$@@@@@@@@$ X$#@@@@@@@$ $@@@@@@@@@$ &-======",
+"====-X .&.%%%%%%&.. .&&&&&. &%&X .@@@@@@@$$ .$$#@@@@@@$ $@@@@@@@@@#$ +=======",
+"====-X &. %%%%%%%%%& &%&& % . X#@@@@@@$ .$.@@@@@@#. .@@@@@@@@@@@. *=======",
+"====-X &&.%%%%%%%%%%%&... &%% &%XX $@@@@@@@... #.#@@@@@. X@@@@@@@@@@@. .;-======",
+"====-X. &. &%%%%%%%%%%%& .& .%%%%%... .@@@@@@# . . .$.$@@@@$ $$@@@@@@@@@@@. -=======",
+"====-X .&.&%%%%%%%%%%%%&. .%%%%%X& X@@@@@@@. . $..@@@$ .#@#@@@@@@@@@@ .--======",
+"====-. && &%%%%%%%%%%%%%& %%%%%.X .@@@@@@#.. $..##$. #@@@@@@@@@@@@# .========",
+"====;X .. .%%%%%%%%%%%%%X %%%%%XX .@@@@@@#... #..##$ .@@@@@@@@@@@@@# .-=======",
+"====;. .& &%%%%%%%%%%%%%& &%%%%%& $#@@@@@$ . . $..#$. $@@@@@@@@@@@@@$ X========",
+"====-X && &%%%%%%%%%%%%%X ....%%%%%X. .@@@@@#$ $$ $$ $@@@@@@@@@@@@@@. *-=======",
+"====-X &X.&%%%%%%%%%%%%%. .. &%%%%%X. $#@@@@@. $ $ .@@@@@@@@@@@@@@@. *-=======",
+"====-. .& &%%%%%%%%%%%%%X .& .&%%%%%X. $@@@@@@. $. . $@@@@@@@@@@@@@@@. *========",
+"====-X &&.&%%%%%%%%%%%%%. &&%X.. &%%%%%... X@@@@@@$ $... $$@@@@@@@@@@@@@@# ;========",
+"====-X .& &%%%%%%%%%%%%%. &%%%%%& .%%%%&. .@@@@@# $.. .$@@@@@@@@@@@@@@@$ .--=======",
+"=====X && &%%%%%%%%%%%%%. &%%%%%& ..&%%%%.. .@@@@@@. .. $#@@@@@@@@@@@@@@.. .=========",
+"====-$ .&..%%%%%%%%%%%%%. &%%%%%%%%%%%%%%X @@@@@#$ ... .#@@@@@@@@@@@@#$ .=========",
+"=====. .& &%%%%%%%%%%%%%. .%%%%%%%%%%%%%%%.. #@@@@#. . $@@@@@@@@@@@#. X=========",
+"=====X .& &%%%%%%%%%%%%% &%%%%%%%%%%%%%%X @@@@@@. .@@@@@@@@@@#. .X=========",
+"=====X. && &%%%%%%%%%%%%%. .%%%%%%%%%%%%%%%X. $@@@@@@.. .... .#@@@@@@@$.. *=========",
+"====-$ &.&%%%%%%%%%%%%& .%%%%%%%%%%%%%%%. $@@@@@@. ....... #@@@@@@#.. .*=========",
+"=====X & &%%%%%%%%%%%%% &%%%%%%%%%%%%%%%.. $@@@@@@. .$@$ . .@@@@@$ .--========",
+"====-X &.&%%%%%%%%%%%%% &%%%%%%%%%%%%%%%. $@@@@@@. #@@@#. #@@#$ .*=========",
+"=====X .& &%%%%%%%%%%%%& &%%%%%%%%%%%%%%%.. $@@@@@@.. $#@@@@#. #@#.. X-=========",
+"=====. &.&%%%%%%%%%%%%%. %%%%%%%%%%%%%%%%. $@@@@@@. $@@@@@@@@. .##$. X==========",
+"=====$ ..%%%%%%%%%%%%%& &%%%%%%%%%%%%%%%.. #@@@@@@. @@@@@@@@@@.. .#@##. +==========",
+"=====X ....%%%%%%%%%%%%%& .&%%%%%%%%%%%%%%%. #@@@@@@. #@@@@@@@@@@@#$ $$#@@#. *--X.======",
+"=====$ ....%%%%%%%%%%%%%& %%%%%%%%%%%%%%%%. #@@@@@$ .@@@@@@@@@@@@@#$ .@@@@@$. XX *=====",
+"====-$ &...%%%%%%%%%%%%%& .%%%%%%%%%%%%%%%%. #@@@@@# @@@@@@@@@@@@@@$$. X@@@@@#$ . .======",
+"=====$ ..& %%%%%%%%%%%%%& %%%%%%%%%%%%%%%%. #@@@@@$ .@@@@@@@@@@@@@@@@@@@@@@@@@.. ;======",
+"=====; &&..%%%%%%%%%%%%%%X .%%%%%%%%%%%%%%%%. .#@@@@@$ X@@@@@@@@@@@@@@@@@@@@@@@@#$ .X========",
+"======X.%.&&%%%%%%%%%%%%%%& .%%%%%%%%%%%%%%%% @@@@@@$ X@@@@@@@@@@@@@@@@@@@@@@@@$ *;*.-======",
+"======X &...&%%%%%%%%%%%%%%. .%%%%%%%%%%%%%%%% .@@@@@@$ $@@@@@@@@@@@@@@@@@@@@@@@#. .*. .==-====",
+"======;X. ...%%%%%%%%%%%%%%X .%%%%%%%%%%%%%%%% .@@@@@@$ #@@@@@@@@@@@@@@@@@@@@@@$ . ;-======",
+"========;.. ....%%%%%%%%%%%%%%. %%%%%%%%%%%%%%%% X@@@@@@ @@@@@@@@@@@@@@@@@@@@@#$ .X X*========",
+"========-X .. . .&%%%%%%%%%%%%&&%%%%%%%%%%%%%%%& $#@@@@# ..#@@@@@@@@@@@@@@@@@@@# .*. -==========",
+"=========$ ... . &%%%%%%%%%%%%%%%%%%%%%%%%%%%%% X@@@@@@. ..@@@@@@@@@@@@@@@@@@@$. XX X;===========",
+"=========XX.XX. &%%%%%%%%%%%%%%%%%%%%%%%%%%%& $@@@@@@$ .#@@@@@@@@@@@@@@@@@#.. X -============",
+"=========-X-&XX.. X%%%%%%%%%%%%%%%%%%%%%%%%%%& $@@@@@@$ . X#@@@@@@@@@@@@@@@@@#... .-==============",
+"============-XX*X X%%%%%%%%%%%%%%%%%%%%%%%%%& $@@@@@#...#@@@@@@@@@@@@@@@@@@... *================",
+"==============$X;*. ..%%%%%%%%%%%%%%%%%%%%%%%%X #@@@@$..@@@@@@@@@@@@@@@@@@@@... .-=================",
+"===============*X*$.. .%%%%%%%%%%%%%%%%%%%%%%%& $@@@@$.@@@@@@@@@@@@@@@@@@@X . ;===================",
+"================;X&*. . %%%%%%%%%%%%%%%%%%%%%%. @@@@@@@@@@@@@@@@@@@@@@@@#. X-====================",
+"==================+$*. &%%%%%%%%%%%%%%%%%%%%. @@@@@@@@@@@@@@@@@@@@@@@$ .-======================",
+"==================-*.*... &%%%%%%%%%%%%%%%%%%%. .#@@@@@@@@@@@@@@@@@@@@@. .X========================",
+"====================;XX.. .%%%%%%%%%%%%%%%%%%. .#@@@@@@@@@@@@@@@@@@@$ .-=========================",
+"=====================-XX. X%%%%%%%%%%%%%%%%% @@@@@@@@@@@@@@@@@@@. *===========================",
+"=======================XX .. .%%%%%%%%%%%%%%%&. .@@@@@@@@@@@@@@@@@# X=============================",
+"========================*X... .%%%%%%%%%%%%%%& .@@@@@@@@@@@@@@@@. ;==============================",
+"=========================-XX... .%%%%%%%%%%%%%& X@@@@@@@@@@@@@@$ X================================",
+"===========================*.... .%%%%%%%%%%%%& .@@@@@@@@@@@@#. -=================================",
+"============================;... &%%%%%%%%%%X X@@@@@@@@@@@.. X===================================",
+"=============================;X.. .+%%%%%%%%%.. $@@@@@@@@@#. .=====================================",
+"===============================X.. X%%%%%%%%. $@@@@@@@@. . ;======================================",
+"================================;X. ..+%%%%%%%. $@@@@@@#$ X========================================",
+"=================================-XX X;%%%%%. $@@@@@@$ . .;=========================================",
+"===================================;.. ..*%%%& . $@@@@X.. X===========================================",
+"=====================================* X%%%. . #@@.. . ;============================================",
+"=====================================-*. .XX&.. $$ . .. X==============================================",
+"=======================================$. .X... *==-============================================",
+"========================================$.. XX:X +=================================================",
+"=========================================X... .*;X *-=-===============================================",
+"==========================================;.. . .X;X .*===================================================",
+"===========================================-... ..X -====================================================",
+"============================================-X. +;======================================================",
+"=============================================-. *==-====================================================",
+"==============================================$ *========================================================",
+"=============================================== X=========================================================",
+"===========================================================================================================",
+"===========================================================================================================",
+"==========================================================================================================="
+};
diff --git a/examples/neil/notebook.py b/examples/neil/notebook.py
new file mode 100755
index 00000000..5b9704ab
--- /dev/null
+++ b/examples/neil/notebook.py
@@ -0,0 +1,63 @@
+#!/usr/bin/env python
+
+from gtk import *
+
+def destroy(args):
+ window.destroy()
+ mainquit()
+
+
+window = GtkWindow()
+window.connect("destroy", destroy)
+window.set_title('Notebook')
+window.border_width(0)
+window.set_usize(400, 400)
+
+box1 = GtkVBox()
+window.add(box1)
+box1.show()
+
+box2 = GtkVBox(spacing=10)
+box2.border_width(10)
+box1.pack_start(box2)
+box2.show()
+
+notebook = GtkNotebook()
+notebook.set_tab_pos(POS_TOP)
+box2.pack_start(notebook)
+notebook.show()
+
+names = ['Background', 'Colors', 'System', 'Setup', 'Samba']
+
+for i in range(len(names)):
+ buffer = names[i]
+ frame = GtkFrame(buffer)
+ frame.border_width(10)
+ frame.set_usize(200, 300)
+ frame.set_shadow_type(SHADOW_ETCHED_OUT)
+ frame.show()
+
+ label = GtkLabel(buffer)
+ frame.add(label)
+ label.show()
+
+ label = GtkLabel(buffer)
+ label.set_padding(2, 2)
+ notebook.append_page(frame, label)
+
+separator = GtkHSeparator()
+box1.pack_start(separator)
+separator.show()
+
+box3 = GtkVBox(spacing=10)
+box3.border_width(10)
+box1.pack_start(box3)
+box3.show()
+
+button = GtkButton(label='close')
+box3.pack_start(button)
+button.connect('clicked', destroy)
+button.show()
+
+window.show()
+mainloop()
diff --git a/examples/neil/question.xpm b/examples/neil/question.xpm
new file mode 100644
index 00000000..8cf1e088
--- /dev/null
+++ b/examples/neil/question.xpm
@@ -0,0 +1,42 @@
+/* XPM */
+static char * question_xpm[] = {
+/**/
+"23 33 4 1",
+/**/
+" s None c none",
+". c black",
+"X c yellow",
+"O c midnightblue",
+" ..... ",
+" ..XXXX.. ",
+" ..XXX....... ",
+" .XXX.......... ",
+" .XX... ..... ",
+" .XX... ..... ",
+" .XX... ..... ",
+" .XX.. ..... ",
+" .X... .....",
+" ..... OOOO .....",
+" ... OO OO .....",
+" OO .....",
+" O .X...",
+" .X... ",
+" O .X... ",
+" O .XX.. ",
+" .XX.. ",
+" .XX.. ",
+" .XX.. ",
+" .XX.. ",
+" .XX.. ",
+" .XX.. ",
+" .X... ",
+" .X... ",
+" .X... ",
+" .X... ",
+" .. ..... ",
+" . . ... ",
+" . ",
+" . ... ",
+" .X... ",
+" . .X... ",
+" ... "};
diff --git a/examples/simple/.cvsignore b/examples/simple/.cvsignore
new file mode 100644
index 00000000..c2831020
--- /dev/null
+++ b/examples/simple/.cvsignore
@@ -0,0 +1,6 @@
+Makefile.in
+Makefile
+*~
+*.pyc
+*.pyo
+
diff --git a/examples/simple/README b/examples/simple/README
new file mode 100644
index 00000000..9bcb80cc
--- /dev/null
+++ b/examples/simple/README
@@ -0,0 +1,5 @@
+These are some of the simplest examples you can do. They are only intended
+to help you see how to use pygtk. The examples ending in 1.py use the low
+level C-like interface, while the ones ending in 2.py are translations that
+use Gtkinter.
+
diff --git a/examples/simple/dnd.py b/examples/simple/dnd.py
new file mode 100644
index 00000000..f5bf6d75
--- /dev/null
+++ b/examples/simple/dnd.py
@@ -0,0 +1,77 @@
+#!/usr/bin/env python
+from gtk import *
+
+# a nice easy to read fixed spacing font.
+font = load_font("-*-lucidatypewriter-medium-r-*-*-14-*-*-*-*-*-*-*")
+
+list = "abcdefghijklmnopqrstuvwxyz" + \
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + \
+ "0123456789" + \
+ "`~!@#$%^&*()-_=+\|[]{};:'\",.<>/? "
+printable = ''
+for c in map(chr, range(256)):
+ if c in list:
+ printable = printable + c
+ else:
+ printable = printable + '.'
+del list, c
+
+def format_line(str):
+ hexstr = reduce(lambda x, a: x + hex(256+ord(a))[-2:] + ' ', str, '')
+ if len(hexstr) < 48:
+ hexstr = (hexstr + ' '*48)[:48]
+ return hexstr + ' ' + reduce(lambda x, a: x + printable[ord(a)],str,'')
+
+def format_data(str):
+ ret = ''
+ while len(str) > 16:
+ line = str[:16]
+ str = str[16:]
+ ret = ret + format_line(line) + '\n'
+ if str: ret = ret + format_line(str)
+ return ret
+
+def dnd_drop(b, event):
+ data_type.set(event.data_type)
+ data.delete_text(0, data.get_length())
+ data.insert(font, black, white, format_data(event.data))
+ pass
+
+win = GtkWindow()
+win.set_title("Drag to Me")
+win.border_width(10)
+
+t = GtkTable(5,4)
+win.add(t)
+t.show()
+
+l = GtkLabel("Data Type")
+l.set_justify(JUSTIFY_RIGHT)
+t.attach(l, 0,1, 0,1, xoptions=FILL)
+l.show()
+
+data_type = GtkLabel("*None*")
+data_type.set_justify(JUSTIFY_LEFT)
+t.attach(data_type, 1,2, 0,1)
+data_type.show()
+
+l = GtkLabel("Data")
+l.set_justify(JUSTIFY_RIGHT)
+t.attach(l, 0,1, 1,2, xoptions=FILL)
+l.show()
+
+data = GtkText()
+data.set_usize(600, -1)
+style = data.get_style()
+white = style.white
+black = style.black
+t.attach(data, 1,2, 1,2)
+data.show()
+
+win.connect("drop_data_available_event", dnd_drop)
+win.dnd_drop_set(TRUE, ['text/plain', 'application/x-color', 'ALL'], FALSE)
+
+win.connect("destroy", mainquit)
+win.show()
+
+mainloop()
diff --git a/examples/simple/hello1.py b/examples/simple/hello1.py
new file mode 100755
index 00000000..60b9ab18
--- /dev/null
+++ b/examples/simple/hello1.py
@@ -0,0 +1,32 @@
+#!/usr/bin/env python
+
+# this is a translation of "Hello World III" from the GTK manual,
+# using gtkmodule
+
+from _gtk import *
+from GTK import *
+
+def hello(*args):
+ print "Hello World"
+ gtk_widget_destroy(window)
+
+def destroy(*args):
+ gtk_widget_hide(window)
+ gtk_main_quit()
+
+gtk_init()
+
+window = gtk_window_new(WINDOW_TOPLEVEL)
+gtk_signal_connect(window, "destroy", destroy)
+gtk_container_border_width(window, 10)
+
+button = gtk_button_new_with_label("Hello World")
+gtk_signal_connect(button, "clicked", hello)
+gtk_container_add(window, button)
+gtk_widget_show(button)
+
+gtk_widget_show(window)
+
+gtk_main()
+
+
diff --git a/examples/simple/hello2.py b/examples/simple/hello2.py
new file mode 100755
index 00000000..b247f523
--- /dev/null
+++ b/examples/simple/hello2.py
@@ -0,0 +1,29 @@
+#!/usr/bin/env python
+
+# this is a translation of "Hello World III" from the GTK manual,
+# using gtk.py
+
+from gtk import *
+
+def hello(*args):
+ print "Hello World"
+ window.destroy()
+
+def destroy(*args):
+ window.hide()
+ mainquit()
+
+window = GtkWindow(WINDOW_TOPLEVEL)
+window.connect("destroy", destroy)
+window.border_width(10)
+
+button = GtkButton("Hello World")
+button.connect("clicked", hello)
+window.add(button)
+button.show()
+
+window.show()
+
+mainloop()
+
+
diff --git a/examples/simple/scribble.py b/examples/simple/scribble.py
new file mode 100755
index 00000000..d0aee9e0
--- /dev/null
+++ b/examples/simple/scribble.py
@@ -0,0 +1,81 @@
+#!/usr/bin/env python
+
+#this is a simple translation of the scribble example that comes with GTK+
+
+import sys
+from gtk import *
+
+pixmap = None
+
+def configure_event(widget, event):
+ global pixmap
+ win = widget.get_window()
+ pixmap = create_pixmap(win, win.width, win.height, -1)
+ draw_rectangle(pixmap, widget.get_style().white_gc, TRUE,
+ 0, 0, win.width, win.height)
+ return TRUE
+
+def expose_event(widget, event):
+ area = event.area
+ gc = widget.get_style().fg_gc[STATE_NORMAL]
+ widget.draw_pixmap(gc, pixmap, area[0], area[1], area[0], area[1],
+ area[2], area[3])
+ return FALSE
+
+def draw_brush(widget, x, y):
+ rect = (x-5, y-5, 10, 10)
+ draw_rectangle(pixmap, widget.get_style().black_gc, TRUE,
+ x-5, y-5, 10, 10)
+ widget.queue_draw()
+
+def button_press_event(widget, event):
+ if event.button == 1 and pixmap != None:
+ draw_brush(widget, event.x, event.y)
+ return TRUE
+
+def motion_notify_event(widget, event):
+ if event.is_hint:
+ x, y = event.window.pointer
+ state = event.window.pointer_state
+ else:
+ x = event.x; y = event.y
+ state = event.state
+ if state & GDK.BUTTON1_MASK and pixmap != None:
+ draw_brush(widget, x, y)
+ return TRUE
+
+def main():
+ win = GtkWindow()
+ win.set_name("Test Input")
+ win.connect("destroy", mainquit)
+ win.border_width(5)
+
+ vbox = GtkVBox(spacing=3)
+ win.add(vbox)
+ vbox.show()
+
+ drawing_area = GtkDrawingArea()
+ drawing_area.size(200, 200)
+ vbox.pack_start(drawing_area)
+ drawing_area.show()
+
+ drawing_area.connect("expose_event", expose_event)
+ drawing_area.connect("configure_event", configure_event)
+ drawing_area.connect("motion_notify_event", motion_notify_event)
+ drawing_area.connect("button_press_event", button_press_event)
+ drawing_area.set_events(GDK.EXPOSURE_MASK |
+ GDK.LEAVE_NOTIFY_MASK |
+ GDK.BUTTON_PRESS_MASK |
+ GDK.POINTER_MOTION_MASK |
+ GDK.POINTER_MOTION_HINT_MASK)
+
+ button = GtkButton("Quit")
+ vbox.pack_start(button, expand=FALSE, fill=FALSE)
+ button.connect("clicked", win.destroy)
+ button.show()
+ win.show()
+ mainloop()
+
+if __name__ == '__main__':
+ main()
+
diff --git a/examples/simple/simple1.py b/examples/simple/simple1.py
new file mode 100755
index 00000000..63980ecd
--- /dev/null
+++ b/examples/simple/simple1.py
@@ -0,0 +1,37 @@
+#!/usr/bin/env python
+
+# translation of "Hello World III" from GTK manual, using gtk_object_new
+# with gtkmodule
+
+from _gtk import *
+from GTK import *
+
+def hello(*args):
+ print "Hello World"
+ gtk_widget_destroy(window)
+
+def destroy(*args):
+ gtk_widget_hide(window)
+ gtk_main_quit()
+
+gtk_init()
+
+window = gtk_object_new(gtk_window_get_type(), {
+ 'type': WINDOW_TOPLEVEL,
+ 'title': 'Hello World',
+ 'allow_grow': 0,
+ 'allow_shrink': 0,
+ 'border_width': 10
+})
+gtk_signal_connect(window, "destroy", destroy)
+
+button = gtk_object_new(gtk_button_get_type(), {
+ 'label': 'Hello World',
+ 'parent': window,
+ 'visible': 1
+})
+gtk_signal_connect(button, "clicked", hello);
+
+gtk_widget_show(window)
+gtk_main()
+
diff --git a/examples/simple/simple2.py b/examples/simple/simple2.py
new file mode 100755
index 00000000..f541b275
--- /dev/null
+++ b/examples/simple/simple2.py
@@ -0,0 +1,26 @@
+#!/usr/bin/env python
+
+# translation of "Hello World III" from gtk manual, using the new() function
+# from gtk.py
+
+from gtk import *
+
+def hello(*args):
+ print "Hello World"
+ window.destroy()
+
+def destroy(*args):
+ window.hide()
+ mainquit()
+
+window = new(GtkWindow, type=WINDOW_TOPLEVEL, title='Hello World',
+ allow_grow=FALSE, allow_shrink=FALSE, border_width=10)
+window.connect("destroy", destroy)
+
+print ""
+button = new(GtkButton, label="Hello World", parent=window, visible=TRUE)
+button.connect("clicked", hello)
+
+window.show_all()
+mainloop()
+
diff --git a/examples/simple/tooltip1.py b/examples/simple/tooltip1.py
new file mode 100755
index 00000000..93f0bcda
--- /dev/null
+++ b/examples/simple/tooltip1.py
@@ -0,0 +1,43 @@
+#!/usr/bin/env python
+
+# translation of "Hello World III" from GTK manual, using gtk_object_new
+# with gtkmodule. Also implements a tooltip for the button.
+
+from _gtk import *
+from GTK import *
+
+def hello(*args):
+ print "Hello World"
+ gtk_widget_destroy(window)
+
+def destroy(*args):
+ gtk_widget_hide(window)
+ gtk_main_quit()
+
+gtk_init()
+
+tt = gtk_tooltips_new()
+gtk_tooltips_set_delay(tt, 500)
+
+window = gtk_object_new("GtkWindow", {
+ 'type': WINDOW_TOPLEVEL,
+ 'title': 'Hello World',
+ 'allow_grow': 0,
+ 'allow_shrink': 0,
+ 'border_width': 10
+})
+gtk_signal_connect(window, "destroy", destroy)
+
+button = gtk_object_new("GtkButton", {
+ 'label': 'Hello World',
+ 'parent': window,
+ 'visible': 1
+})
+gtk_signal_connect(button, "clicked", hello)
+
+gtk_tooltips_set_tip(tt, button, 'Prints "Hello World"', '')
+gtk_tooltips_enable(tt)
+
+gtk_widget_show(window)
+gtk_main()
+
diff --git a/examples/simple/tooltip2.py b/examples/simple/tooltip2.py
new file mode 100755
index 00000000..3fad341b
--- /dev/null
+++ b/examples/simple/tooltip2.py
@@ -0,0 +1,32 @@
+#!/usr/bin/env python
+
+# translation of "Hello World III" from GTK manual, using new() function
+# from gtk.py. Also implements a tooltip for the button.
+
+from gtk import *
+
+def hello(*args):
+ print "Hello World"
+ window.destroy()
+
+def destroy(*args):
+ window.hide()
+ mainquit()
+
+tt = GtkTooltips()
+tt.set_delay(500)
+
+window = new(GtkWindow, type=WINDOW_TOPLEvEL, title="Hello World",
+ allow_grow=FALSE, allow_shrink=FALSE, border_width=10)
+window.connect("destroy", destroy)
+
+button = new(GtkButton, label="Hello World", parent=window, visible=TRUE)
+button.connect("clicked", hello)
+
+tt.set_tip(button, 'Prints "Hello World"', '')
+tt.enable()
+
+window.show()
+mainloop()
+
+
diff --git a/examples/testgtk/.cvsignore b/examples/testgtk/.cvsignore
new file mode 100644
index 00000000..c2831020
--- /dev/null
+++ b/examples/testgtk/.cvsignore
@@ -0,0 +1,6 @@
+Makefile.in
+Makefile
+*~
+*.pyc
+*.pyo
+
diff --git a/examples/testgtk/README b/examples/testgtk/README
new file mode 100644
index 00000000..739eeae2
--- /dev/null
+++ b/examples/testgtk/README
@@ -0,0 +1,4 @@
+This directory contains a translation of most of the testgtk example found
+in the gtk distribution. I wrote it mainly to iron out bugs in pygtk, but
+it is also useful to see how to use the various widgets.
+
diff --git a/examples/testgtk/test.xpm b/examples/testgtk/test.xpm
new file mode 100644
index 00000000..9b0d2efd
--- /dev/null
+++ b/examples/testgtk/test.xpm
@@ -0,0 +1,92 @@
+/* XPM */
+static char *openfile[] = {
+/* width height num_colors chars_per_pixel */
+" 20 19 66 2",
+/* colors */
+".. c None",
+".# c #000000",
+".a c #dfdfdf",
+".b c #7f7f7f",
+".c c #006f6f",
+".d c #00efef",
+".e c #009f9f",
+".f c #004040",
+".g c #00bfbf",
+".h c #ff0000",
+".i c #ffffff",
+".j c #7f0000",
+".k c #007070",
+".l c #00ffff",
+".m c #00a0a0",
+".n c #004f4f",
+".o c #00cfcf",
+".p c #8f8f8f",
+".q c #6f6f6f",
+".r c #a0a0a0",
+".s c #7f7f00",
+".t c #007f7f",
+".u c #5f5f5f",
+".v c #707070",
+".w c #00f0f0",
+".x c #009090",
+".y c #ffff00",
+".z c #0000ff",
+".A c #00afaf",
+".B c #00d0d0",
+".C c #00dfdf",
+".D c #005f5f",
+".E c #00b0b0",
+".F c #001010",
+".G c #00c0c0",
+".H c #000f0f",
+".I c #00007f",
+".J c #005050",
+".K c #002f2f",
+".L c #dfcfcf",
+".M c #dfd0d0",
+".N c #006060",
+".O c #00e0e0",
+".P c #00ff00",
+".Q c #002020",
+".R c #dfc0c0",
+".S c #008080",
+".T c #001f1f",
+".U c #003f3f",
+".V c #007f00",
+".W c #00000f",
+".X c #000010",
+".Y c #00001f",
+".Z c #000020",
+".0 c #00002f",
+".1 c #000030",
+".2 c #00003f",
+".3 c #000040",
+".4 c #00004f",
+".5 c #000050",
+".6 c #00005f",
+".7 c #000060",
+".8 c #00006f",
+".9 c #000070",
+"#. c #7f7f80",
+"## c #9f9f9f",
+/* pixels */
+"........................................",
+"........................................",
+"........................................",
+".......................#.#.#............",
+".....................#.......#...#......",
+"...............................#.#......",
+".......#.#.#.................#.#.#......",
+".....#.y.i.y.#.#.#.#.#.#.#..............",
+".....#.i.y.i.y.i.y.i.y.i.#..............",
+".....#.y.i.y.i.y.i.y.i.y.#..............",
+".....#.i.y.i.y.#.#.#.#.#.#.#.#.#.#.#....",
+".....#.y.i.y.#.s.s.s.s.s.s.s.s.s.#......",
+".....#.i.y.#.s.s.s.s.s.s.s.s.s.#........",
+".....#.y.#.s.s.s.s.s.s.s.s.s.#..........",
+".....#.#.s.s.s.s.s.s.s.s.s.#............",
+".....#.#.#.#.#.#.#.#.#.#.#..............",
+"........................................",
+"........................................",
+"........................................"
+};
diff --git a/examples/testgtk/testgtk.py b/examples/testgtk/testgtk.py
new file mode 100755
index 00000000..e6fd168c
--- /dev/null
+++ b/examples/testgtk/testgtk.py
@@ -0,0 +1,1525 @@
+#!/usr/bin/env python
+
+from gtk import *
+import GtkExtra
+
+wins = {}
+
+def delete_event(win, event=None):
+ win.hide()
+ # don't destroy window -- just leave it hidden
+ return TRUE
+
+def create_statusbar_test(_button):
+ if not wins.has_key('statusbar_test'):
+ win = GtkDialog()
+ wins["statusbar_test"] = win
+ win.connect("delete_event", delete_event)
+ win.set_title("Status Bar Test")
+
+ vbox = GtkVBox()
+ win.action_area.pack_start( vbox )
+ hbox = GtkHBox()
+ vbox.add( hbox )
+ statusbar = win.statusbar = GtkStatusbar()
+ vbox.add( statusbar )
+ statusbar.show()
+
+ c = win.context_id = statusbar.get_context_id("test")
+ statusbar.push( c, "First message")
+ def pop_statusbar_test(_b, sbar = statusbar, context = c):
+ sbar.pop( context )
+ def push_statusbar_test(_b, sbar = statusbar, context = c):
+ import time
+ sbar.push( context, "Message "+str(time.time() ))
+
+ button = GtkButton("Pop")
+ button.connect("clicked", pop_statusbar_test)
+ hbox.add(button)
+ button.show()
+
+ button = GtkButton("Push")
+ button.connect("clicked", push_statusbar_test)
+ hbox.add(button)
+ button.show()
+
+ button = GtkButton("close")
+ button.connect("clicked", win.hide)
+ hbox.add(button)
+ button.set_flags(CAN_DEFAULT)
+ button.grab_default()
+ button.show()
+
+ hbox.show()
+ vbox.show()
+ wins["statusbar_test"].show()
+
+
+def create_buttons(_button):
+ if not wins.has_key("buttons"):
+ win = GtkWindow()
+ wins["buttons"] = win
+ win.connect("delete_event", delete_event)
+ win.set_title("buttons")
+ box1 = GtkVBox()
+ win.add(box1)
+ box1.show()
+ table = GtkTable(3, 3, FALSE)
+ table.set_row_spacings(5)
+ table.set_col_spacings(5)
+ table.border_width(10)
+ box1.pack_start(table)
+ table.show()
+
+ def toggle_show(b):
+ if b.flags(VISIBLE):
+ b.hide()
+ else:
+ b.show()
+ button = map(lambda i: GtkButton("button"+str(i)), range(9))
+ for i in range(9):
+ button[i].connect("clicked",
+ lambda _b, _b2=button[(i+1)%9],
+ t=toggle_show: t(_b2))
+ y,x = divmod(i, 3)
+ table.attach(button[i], x,x+1, y,y+1)
+ button[i].show()
+
+ separator = GtkHSeparator()
+ box1.pack_start(separator, expand=FALSE)
+ separator.show()
+
+ box2 = GtkVBox(spacing=10)
+ box2.border_width(10)
+ box1.pack_start(box2, expand=FALSE)
+ box2.show()
+
+ button = GtkButton("close")
+ button.connect("clicked", win.hide)
+ box2.pack_start(button)
+ button.set_flags(CAN_DEFAULT)
+ button.grab_default()
+ button.show()
+ wins["buttons"].show()
+
+def create_toggle_buttons(_button):
+ if not wins.has_key("toggle_buttons"):
+ win = GtkWindow()
+ wins["toggle_buttons"] = win
+ win.connect("delete_event", delete_event)
+ win.set_title("toggle butttons")
+ win.border_width(0)
+ box1 = GtkVBox()
+ win.add(box1)
+ box1.show()
+
+ box2 = GtkVBox(spacing=10)
+ box2.border_width(10)
+ box1.pack_start(box2)
+ box2.show()
+ for i in range(1, 4):
+ button = GtkToggleButton("button" + str(i))
+ box2.pack_start(button)
+ button.show()
+ separator = GtkHSeparator()
+ box1.pack_start(separator, expand=FALSE)
+ separator.show()
+
+ box2 = GtkVBox(spacing=10)
+ box2.border_width(10)
+ box1.pack_start(box2, expand=FALSE)
+ box2.show()
+
+ button = GtkButton("close")
+ button.connect("clicked", win.hide)
+ box2.pack_start(button)
+ button.set_flags(CAN_DEFAULT)
+ button.grab_default()
+ button.show()
+ wins["toggle_buttons"].show()
+
+def create_check_buttons(_button):
+ if not wins.has_key("check_buttons"):
+ win = GtkWindow()
+ wins["check_buttons"] = win
+ win.connect("delete_event", delete_event)
+ win.set_title("check buttons")
+ box1 = GtkVBox()
+ win.add(box1)
+ box1.show()
+
+ box2 = GtkVBox(spacing=10)
+ box2.border_width(10)
+ box1.pack_start(box2)
+ box2.show()
+
+ for i in range(1,4):
+ button = GtkCheckButton("button" + str(i))
+ box2.pack_start(button)
+ button.show()
+ separator = GtkHSeparator()
+ box1.pack_start(separator, expand=FALSE)
+ separator.show()
+
+ box2 = GtkVBox(spacing=10)
+ box2.border_width(10)
+ box1.pack_start(box2, expand=FALSE)
+ box2.show()
+
+ button = GtkButton("close")
+ button.connect("clicked", win.hide)
+ box2.pack_start(button)
+ button.set_flags(CAN_DEFAULT)
+ button.grab_default()
+ button.show()
+ wins["check_buttons"].show()
+
+def create_radio_buttons(_button):
+ if not wins.has_key("radio_buttons"):
+ win = GtkWindow()
+ wins["radio_buttons"] = win
+ win.connect("delete_event", delete_event)
+ win.set_title("radio buttons")
+ box1 = GtkVBox()
+ win.add(box1)
+ box1.show()
+
+ box2 = GtkVBox(spacing=10)
+ box2.border_width(10)
+ box1.pack_start(box2)
+ box2.show()
+
+ button1 = GtkRadioButton(None, "button1")
+ box2.pack_start(button1)
+ button1.show()
+ for i in range(2,4):
+ button = GtkRadioButton(button1, "button" + str(i))
+ box2.pack_start(button)
+ button.show()
+ separator = GtkHSeparator()
+ box1.pack_start(separator, expand=FALSE)
+ separator.show()
+
+ box2 = GtkVBox(spacing=10)
+ box2.border_width(10)
+ box1.pack_start(box2, expand=FALSE)
+ box2.show()
+
+ button = GtkButton("close")
+ button.connect("clicked", win.hide)
+ box2.pack_start(button)
+ button.set_flags(CAN_DEFAULT)
+ button.grab_default()
+ button.show()
+ wins["radio_buttons"].show()
+
+def create_button_box(_button):
+ if not wins.has_key("button_box"):
+ win = GtkDialog()
+ win.set_title("button box")
+ wins["button_box"] = win
+ win.connect("delete_event", delete_event)
+
+ box1 = GtkHButtonBox()
+ box1.set_usize(550, -1)
+ box1.set_spacing(25)
+ box1.set_layout(BUTTONBOX_EDGE)
+ box1.border_width(10)
+ win.vbox.pack_start(box1)
+ box1.show()
+
+ def bbox_start(_b, bbox=box1):
+ bbox.set_layout(BUTTONBOX_START)
+ bbox.queue_resize()
+ def bbox_edge(_b, bbox=box1):
+ bbox.set_layout(BUTTONBOX_EDGE)
+ bbox.queue_resize()
+ def bbox_spread(_b, bbox=box1):
+ bbox.set_layout(BUTTONBOX_SPREAD)
+ bbox.queue_resize()
+ def bbox_end(_b, bbox=box1):
+ bbox.set_layout(BUTTONBOX_END)
+ bbox.queue_resize()
+
+ button = GtkButton("start")
+ button.connect("clicked", bbox_start)
+ box1.add(button)
+ button.show()
+ button = GtkButton("edge")
+ button.connect("clicked", bbox_edge)
+ box1.add(button)
+ button.show()
+ button = GtkButton("spread")
+ button.connect("clicked", bbox_spread)
+ box1.add(button)
+ button.show()
+ button = GtkButton("end")
+ button.connect("clicked", bbox_end)
+ box1.add(button)
+ button.show()
+
+ button = GtkButton("close")
+ button.connect("clicked", win.hide)
+ win.action_area.pack_start(button)
+ button.set_flags(CAN_DEFAULT)
+ button.grab_default()
+ button.show()
+ wins["button_box"].show()
+
+def make_toolbar(win):
+ toolbar = GtkToolbar(ORIENTATION_HORIZONTAL, TOOLBAR_BOTH)
+ bg = win.get_style().bg[STATE_NORMAL]
+ if not win.flags(REALIZED):
+ win.realize()
+
+ pix, mask = create_pixmap_from_xpm(win, None, "test.xpm")
+
+ def set_toolbar_horizontal(_b, toolbar=toolbar):
+ toolbar.set_orientation(ORIENTATION_HORIZONTAL)
+ def set_toolbar_vertical(_b, toolbar=toolbar):
+ toolbar.set_orientation(ORIENTATION_VERTICAL)
+ def set_toolbar_icons(_b, toolbar=toolbar):
+ toolbar.set_style(TOOLBAR_ICONS)
+ def set_toolbar_text(_b, toolbar=toolbar):
+ toolbar.set_style(TOOLBAR_TEXT)
+ def set_toolbar_both(_b, toolbar=toolbar):
+ toolbar.set_style(TOOLBAR_BOTH)
+ def set_toolbar_small_space(_b, toolbar=toolbar):
+ toolbar.set_space_size(5)
+ def set_toolbar_big_space(_b, toolbar=toolbar):
+ toolbar.set_space_size(10)
+ def set_toolbar_enable(_b, toolbar=toolbar):
+ toolbar.set_tooltips(TRUE)
+ def set_toolbar_disable(_b, toolbar=toolbar):
+ toolbar.set_tooltips(FALSE)
+ print "Hello"
+
+ toolbar.append_item("Horizontal", "Horizontal toolbar layout",
+ "Horizontal toolbar layout",
+ GtkPixmap(pix, mask),
+ set_toolbar_horizontal)
+ toolbar.append_item("Vertical", "Vertical toolbar layout",
+ "Vertical toolbar layout",
+ GtkPixmap(pix, mask),
+ set_toolbar_vertical)
+ toolbar.append_space()
+ toolbar.append_item("Icons", "Only show toolbar icons",
+ "Only Icons",
+ GtkPixmap(pix, mask),
+ set_toolbar_icons)
+ toolbar.append_item("Text", "Only show toolbar text",
+ "Only Text",
+ GtkPixmap(pix, mask),
+ set_toolbar_text)
+ toolbar.append_item("Both", "Show toolbar icons and text",
+ "Both Text and Icons",
+ GtkPixmap(pix, mask),
+ set_toolbar_both)
+ toolbar.append_space()
+
+ entry = GtkEntry()
+ entry.show()
+ toolbar.append_widget(entry, "", "")
+
+ toolbar.append_space()
+ toolbar.append_item("Small", "Use small spaces",
+ "Small spaces",
+ GtkPixmap(pix, mask),
+ set_toolbar_small_space)
+ toolbar.append_item("Big", "Use big spaces",
+ "Big spaces",
+ GtkPixmap(pix, mask),
+ set_toolbar_big_space)
+ toolbar.append_space()
+ toolbar.append_item("Enable", "Enable tooltips",
+ "Enable tooltips",
+ GtkPixmap(pix, mask),
+ set_toolbar_enable)
+ toolbar.append_item("Disable", "Disable tooltips",
+ "Disable tooltips",
+ GtkPixmap(pix, mask),
+ set_toolbar_disable)
+ return toolbar
+
+def create_toolbar(_button):
+ if not wins.has_key("toolbar"):
+ win = GtkWindow()
+ wins["toolbar"] = win
+ win.set_title("Toolbar test")
+ win.set_policy(FALSE, TRUE, TRUE)
+ win.connect("delete_event", delete_event)
+ win.realize()
+ toolbar = make_toolbar(win)
+ win.add(toolbar)
+ toolbar.show()
+ wins["toolbar"].show()
+
+def create_handle_box(_button):
+ if not wins.has_key("handle_box"):
+ win = GtkWindow()
+ wins["handle_box"] = win
+ win.set_title("Handle Box Test")
+ win.connect("delete_event", delete_event)
+ win.border_width(20)
+ win.realize()
+
+ hbox = GtkHandleBox()
+ win.add(hbox)
+ hbox.show()
+
+ toolbar = make_toolbar(win)
+ hbox.add(toolbar)
+ toolbar.show()
+ wins["handle_box"].show()
+
+def create_reparent(_button):
+ if not wins.has_key("reparent"):
+ win = GtkWindow()
+ wins["reparent"] = win
+ win.connect("delete_event", delete_event)
+ win.set_title("buttons")
+
+ box1 = GtkVBox()
+ win.add(box1)
+ box1.show()
+
+ box2 = GtkHBox(spacing=5)
+ box2.border_width(10)
+ box1.pack_start(box2)
+ box2.show()
+
+ label = GtkLabel("Hello World")
+ frame = GtkFrame("Frame 1")
+ box2.pack_start(frame)
+ frame.show()
+ box3 = GtkVBox(spacing=5)
+ box3.border_width(5)
+ frame.add(box3)
+ box3.show()
+ def reparent_label(button, new_parent=box3, label=label):
+ label.reparent(new_parent)
+ button = GtkButton("switch")
+ button.connect("clicked", reparent_label)
+ box3.pack_start(button, expand=FALSE)
+ button.show()
+
+ box3.pack_start(label, expand=FALSE)
+ label.show()
+
+ frame = GtkFrame("Frame 2")
+ box2.pack_start(frame)
+ frame.show()
+ box3 = GtkVBox(spacing=5)
+ box3.border_width(5)
+ frame.add(box3)
+ box3.show()
+ def reparent_label(button, new_parent=box3, label=label):
+ label.reparent(new_parent)
+ button = GtkButton("switch")
+ button.connect("clicked", reparent_label)
+ box3.pack_start(button, expand=FALSE)
+ button.show()
+
+ separator = GtkHSeparator()
+ box1.pack_start(separator, expand=FALSE)
+ separator.show()
+
+ box2 = GtkVBox(spacing=10)
+ box2.border_width(10)
+ box1.pack_start(box2, expand=FALSE)
+ box2.show()
+
+ button = GtkButton("close")
+ button.connect("clicked", win.hide)
+ box2.pack_start(button)
+ button.set_flags(CAN_DEFAULT)
+ button.grab_default()
+ button.show()
+ wins["reparent"].show()
+
+def create_pixmap(_button):
+ if not wins.has_key("pixmap"):
+ win = GtkWindow()
+ wins["pixmap"] = win
+ win.connect("delete_event", delete_event)
+ win.set_title("pixmap")
+ win.realize()
+
+ box1 = GtkVBox()
+ win.add(box1)
+ box1.show()
+
+ box2 = GtkVBox(spacing=10)
+ box2.border_width(10)
+ box1.pack_start(box2)
+ box2.show()
+
+ button = GtkButton()
+ box2.pack_start(button, expand=FALSE, fill=FALSE)
+ button.show()
+
+ pixmap = GtkPixmap(win, "test.xpm",
+ button.get_style().bg[STATE_NORMAL])
+ label = GtkLabel("Pixmap\ntest")
+ box3 = GtkHBox()
+ box3.border_width(2)
+ box3.add(pixmap)
+ box3.add(label)
+ button.add(box3)
+ pixmap.show()
+ label.show()
+ box3.show()
+
+ separator = GtkHSeparator()
+ box1.pack_start(separator, expand=FALSE)
+ separator.show()
+
+ box2 = GtkVBox(spacing=10)
+ box2.border_width(10)
+ box1.pack_start(box2, expand=FALSE)
+ box2.show()
+ button = GtkButton("close")
+ button.connect("clicked", win.hide)
+ box2.pack_start(button)
+ button.set_flags(CAN_DEFAULT)
+ button.grab_default()
+ button.show()
+ wins["pixmap"].show()
+
+def create_tooltips(_button):
+ if not wins.has_key("tooltips"):
+ win = GtkWindow()
+ wins["tooltips"] = win
+ win.connect("delete_event", delete_event)
+ win.set_title("tooltips")
+
+ tooltips = GtkTooltips()
+
+ box1 = GtkVBox()
+ win.add(box1)
+ box1.show()
+
+ box2 = GtkVBox(spacing=10)
+ box2.border_width(10)
+ box1.pack_start(box2)
+ box2.show()
+
+ button = GtkToggleButton("button1")
+ box2.pack_start(button)
+ button.show()
+ tooltips.set_tip(button, "This is button 1", "button 1")
+
+ button = GtkToggleButton("button2")
+ box2.pack_start(button)
+ button.show()
+ tooltips.set_tip(button, "This is button 2", "button 2")
+
+ button = GtkToggleButton("button3")
+ box2.pack_start(button)
+ button.show()
+ tooltips.set_tip(button, "This is button 3. This is also a really long tooltip which probably won't fit on a single line and will therefore need to be wrapped. Hopefully the wrapping will work correctly.", "long")
+
+ separator = GtkHSeparator()
+ box1.pack_start(separator, expand=FALSE)
+ separator.show()
+
+ box2 = GtkVBox(spacing=10)
+ box2.border_width(10)
+ box1.pack_start(box2, expand=FALSE)
+ box2.show()
+
+ button = GtkButton("close")
+ button.connect("clicked", win.hide)
+ box2.pack_start(button)
+ button.set_flags(CAN_DEFAULT)
+ button.grab_default()
+ button.show()
+
+ tooltips.set_tip(button, "Push this button to close window",
+ "push")
+ tooltips.enable()
+ wins["tooltips"].show()
+
+def create_menu(depth):
+ if depth < 1: return None
+ menu = GtkMenu()
+ group = None
+ for i in range(5):
+ menuitem = GtkRadioMenuItem(group,
+ "item %2d - %d" % (depth, i+1))
+ group = menuitem
+ menu.append(menuitem)
+ menuitem.show()
+ if depth > 1:
+ submenu = create_menu(depth - 1)
+ menuitem.set_submenu(submenu)
+ return menu
+def create_menus(_button):
+ if not wins.has_key("menus"):
+ win = GtkWindow()
+ wins["menus"] = win
+ win.connect("delete_event", delete_event)
+ win.set_title("menus")
+
+ box1 = GtkVBox()
+ win.add(box1)
+ box1.show()
+
+ menubar = GtkMenuBar()
+ box1.pack_start(menubar, expand=FALSE)
+ menubar.show()
+
+ menuitem = GtkMenuItem("test\nline2")
+ menuitem.set_submenu(create_menu(2))
+ menubar.append(menuitem)
+ menuitem.show()
+
+ menuitem = GtkMenuItem("foo")
+ menuitem.set_submenu(create_menu(2))
+ menubar.append(menuitem)
+ menuitem.show()
+
+ menuitem = GtkMenuItem("bar")
+ menuitem.set_submenu(create_menu(2))
+ menuitem.right_justify()
+ menubar.append(menuitem)
+ menuitem.show()
+
+ box2 = GtkVBox(spacing=10)
+ box2.border_width(10)
+ box1.pack_start(box2)
+ box2.show()
+
+ optionmenu = GtkOptionMenu()
+ optionmenu.set_menu(create_menu(1))
+ box2.pack_start(optionmenu)
+ optionmenu.show()
+
+ separator = GtkHSeparator()
+ box1.pack_start(separator, expand=FALSE)
+ separator.show()
+
+ box2 = GtkVBox(spacing=10)
+ box2.border_width(10)
+ box1.pack_start(box2, expand=FALSE)
+ box2.show()
+
+ button = GtkButton("close")
+ button.connect("clicked", win.hide)
+ box2.pack_start(button)
+ button.set_flags(CAN_DEFAULT)
+ button.grab_default()
+ button.show()
+ wins["menus"].show()
+
+def create_scrolled_windows(_button):
+ if not wins.has_key("scrolled_windows"):
+ win = GtkDialog()
+ wins["scrolled_windows"] = win
+ win.connect("delete_event", delete_event)
+ win.set_title("dialog")
+
+ scrolled_window = GtkScrolledWindow()
+ scrolled_window.border_width(10)
+ scrolled_window.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC)
+ win.vbox.pack_start(scrolled_window)
+ scrolled_window.show()
+
+ table = GtkTable(20, 20)
+ table.set_row_spacings(10)
+ table.set_col_spacings(10)
+ scrolled_window.add(table)
+ table.show()
+
+ for i in range(20):
+ for j in range(20):
+ button = GtkToggleButton("button (%d,%d)" %
+ (i, j))
+ table.attach(button, i,i+1, j,j+1)
+ button.show()
+ button = GtkButton("close")
+ button.connect("clicked", win.hide)
+ win.action_area.pack_start(button)
+ button.set_flags(CAN_DEFAULT)
+ button.grab_default()
+ button.show()
+ wins["scrolled_windows"].show()
+
+def create_entry(_button):
+ if not wins.has_key("entry"):
+ win = GtkWindow()
+ wins["entry"] = win
+ win.connect("delete_event", delete_event)
+ win.set_title("entry")
+
+ box1 = GtkVBox()
+ win.add(box1)
+ box1.show()
+
+ box2 = GtkVBox(spacing=10)
+ box2.border_width(10)
+ box1.pack_start(box2)
+ box2.show()
+
+ entry = GtkEntry()
+ entry.set_text("Hello World")
+ box2.pack_start(entry)
+ entry.show()
+
+ separator = GtkHSeparator()
+ box1.pack_start(separator, expand=FALSE)
+ separator.show()
+
+ box2 = GtkVBox(spacing=10)
+ box2.border_width(10)
+ box1.pack_start(box2, expand=FALSE)
+ box2.show()
+
+ button = GtkButton("close")
+ button.connect("clicked", win.hide)
+ box2.pack_start(button)
+ button.set_flags(CAN_DEFAULT)
+ button.grab_default()
+ button.show()
+ wins["entry"].show()
+
+def create_list(_button):
+ if not wins.has_key("list"):
+ win = GtkWindow()
+ wins["list"] = win
+ win.connect("delete_event", delete_event)
+ win.set_title("list")
+
+ box1 = GtkVBox()
+ win.add(box1)
+ box1.show()
+
+ box2 = GtkVBox(spacing=10)
+ box2.border_width(10)
+ box1.pack_start(box2)
+ box2.show()
+
+ scrolled_win = GtkScrolledWindow()
+ scrolled_win.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC)
+ box2.pack_start(scrolled_win)
+ scrolled_win.show()
+
+ list = GtkList()
+ list.set_selection_mode(SELECTION_MULTIPLE)
+ list.set_selection_mode(SELECTION_BROWSE)
+ scrolled_win.add(list)
+ list.show()
+
+ list_items = ("hello", "world", "blah", "foo", "bar", "argh")
+ for i in list_items:
+ list_item = GtkListItem(i)
+ list.add(list_item)
+ list_item.show()
+
+ def list_add(_button, list=list, num=[1]):
+ list_item = GtkListItem("added item "+str(num[0]))
+ num[0] = num[0] + 1
+ list_item.show()
+ list.add(list_item)
+
+ def list_remove(_button, list=list):
+ selection = list.get_selection()
+ list.remove_items(selection)
+ for i in selection: i.destroy()
+
+ box3 = GtkHBox(spacing=10)
+ box2.pack_start(box3, expand=FALSE)
+ box3.show()
+
+ button = GtkButton("add")
+ button.connect("clicked", list_add)
+ box3.pack_start(button)
+ button.show()
+
+ button = GtkButton("remove")
+ button.connect("clicked", list_remove)
+ box3.pack_start(button)
+ button.show()
+
+ separator = GtkHSeparator()
+ box1.pack_start(separator, expand=FALSE)
+ separator.show()
+
+ box2 = GtkVBox(spacing=10)
+ box2.border_width(10)
+ box1.pack_start(box2, expand=FALSE)
+ box2.show()
+
+ button = GtkButton("close")
+ button.connect("clicked", win.hide)
+ box2.pack_start(button)
+ button.set_flags(CAN_DEFAULT)
+ button.grab_default()
+ button.show()
+ wins["list"].show()
+
+def create_clist(_button):
+ if not wins.has_key("clist"):
+ win = GtkWindow()
+ wins["clist"] = win
+ win.connect("delete_event", delete_event)
+ win.set_title("clist")
+
+ box1 = GtkVBox()
+ win.add(box1)
+ box1.show()
+
+ box2 = GtkHBox(spacing=10)
+ box2.border_width(10)
+ box1.pack_start(box2, expand=FALSE, fill=FALSE)
+ box2.show()
+
+ clist = GtkCList(7, map(lambda i: "Title "+str(i), range(7)))
+ clist.set_column_width(0, 100)
+ for i in range(1, 7):
+ clist.set_column_width(i, 80)
+
+ text = map(lambda i: "Column "+str(i), range(7))
+ text[1] = "Right"
+ text[2] = "Center"
+
+ def add1000_clist(_button, clist=clist, t=text):
+ clist.freeze()
+ for i in range(1000):
+ t[0] = "Row "+str(i)
+ clist.append(t)
+ clist.thaw()
+ def add10000_clist(_button, clist=clist, t=text):
+ clist.freeze()
+ for i in range(10000):
+ t[0] = "Row "+str(i)
+ clist.append(t)
+ clist.thaw()
+ def clear_clist(_button, clist=clist):
+ clist.clear()
+ s = [0]
+ def remove_row_clist(_button, clist=clist, selected=s):
+ clist.remove(selected[0])
+ def select_clist(_clist, r, c, event, selected=s):
+ selected[0] = r
+
+ button = GtkButton("Add 1,000 Rows")
+ box2.pack_start(button)
+ button.connect("clicked", add1000_clist)
+ button.show()
+
+ button = GtkButton("Add 10,000 Rows")
+ box2.pack_start(button)
+ button.connect("clicked", add10000_clist)
+ button.show()
+
+ button = GtkButton("Clear List")
+ box2.pack_start(button)
+ button.connect("clicked", clear_clist)
+ button.show()
+
+ button = GtkButton("Remove Row")
+ box2.pack_start(button)
+ button.connect("clicked", remove_row_clist)
+ button.show()
+
+ box2 = GtkHBox(spacing=10)
+ box2.border_width(10)
+ box1.pack_start(box2, expand=FALSE, fill=FALSE)
+ box2.show()
+
+ button = GtkButton("Show Title Buttons")
+ box2.pack_start(button)
+ button.connect("clicked", clist.column_titles_show)
+ button.show()
+
+ button = GtkButton("Hide Title Buttons")
+ box2.pack_start(button)
+ button.connect("clicked", clist.column_titles_hide)
+ button.show()
+
+ box2 = GtkVBox(spacing=10)
+ box2.border_width(10)
+ box1.pack_start(box2)
+ box2.show()
+
+ clist.set_row_height(20)
+ clist.connect("select_row", select_clist)
+ clist.set_column_width(0, 100)
+
+ for i in range(1, 7):
+ clist.set_column_width(0, 80)
+ clist.set_selection_mode(SELECTION_BROWSE)
+ clist.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC)
+ clist.set_column_justification(1, JUSTIFY_RIGHT)
+ clist.set_column_justification(2, JUSTIFY_CENTER)
+
+ for i in range(100):
+ text[0] = "Row "+str(i)
+ clist.append(text)
+ clist.border_width(5)
+ box2.pack_start(clist)
+ clist.show()
+
+ separator = GtkHSeparator()
+ box1.pack_start(separator, expand=FALSE)
+ separator.show()
+
+ box2 = GtkVBox(spacing=10)
+ box2.border_width(10)
+ box1.pack_start(box2, expand=FALSE)
+ box2.show()
+
+ button = GtkButton("close")
+ button.connect("clicked", win.hide)
+ box2.pack_start(button)
+ button.set_flags(CAN_DEFAULT)
+ button.grab_default()
+ button.show()
+ wins["clist"].show()
+
+def create_color_selection(_button):
+ if not wins.has_key("color_selection"):
+ win = GtkColorSelectionDialog("color selection dialog")
+ wins["color_selection"] = win
+ win.colorsel.set_opacity(TRUE)
+ win.colorsel.set_update_policy(UPDATE_CONTINUOUS)
+ win.position(WIN_POS_MOUSE)
+ win.connect("delete_event", delete_event)
+
+ win.cancel_button.connect("clicked", win.hide)
+ wins["color_selection"].show()
+
+def create_file_selection(_button):
+ if not wins.has_key("file_selection"):
+ win = GtkFileSelection("file selection dialog")
+ wins["file_selection"] = win
+ win.connect("delete_event", delete_event)
+ def file_selection_ok(_button, fs=win):
+ print fs.get_filename()
+ win.ok_button.connect("clicked", file_selection_ok)
+ win.cancel_button.connect("clicked", win.hide)
+ wins["file_selection"].show()
+
+def create_dialog(_button):
+ if not wins.has_key("dialog"):
+ win = GtkDialog()
+ wins["dialog"] = win
+ win.connect("delete_event", delete_event)
+ win.set_title("dialog")
+
+ button = GtkButton("OK")
+ button.connect("clicked", win.hide)
+ win.action_area.pack_start(button)
+ button.show()
+
+ def label_toggle(_button, label=[None], box=win.vbox):
+ l = label[0]
+ if not l:
+ l = GtkLabel("Dialog Test")
+ l.set_padding(10, 10)
+ box.pack_start(l)
+ l.show()
+ label[0] = l
+ else:
+ l.destroy()
+ label[0] = None
+
+ button = GtkButton("Toggle")
+ button.connect("clicked", label_toggle)
+ win.action_area.pack_start(button)
+ button.set_flags(CAN_DEFAULT)
+ button.grab_default()
+ button.show()
+ wins["dialog"].show()
+
+def create_range_controls(_button):
+ if not wins.has_key("range_controls"):
+ win = GtkWindow()
+ wins["range_controls"] = win
+ win.connect("delete_event", delete_event)
+ win.set_title("range_controls")
+
+ box1 = GtkVBox()
+ win.add(box1)
+ box1.show()
+
+ box2 = GtkVBox(spacing=10)
+ box2.border_width(10)
+ box1.pack_start(box2)
+ box2.show()
+
+ adjustment = GtkAdjustment(0, 0, 101, 0.1, 1, 1)
+
+ scale = GtkHScale(adjustment)
+ scale.set_usize(150, 30)
+ scale.set_update_policy(UPDATE_DELAYED)
+ scale.set_digits(1)
+ scale.set_draw_value(TRUE)
+ box2.pack_start(scale)
+ scale.show()
+
+ scrollbar = GtkHScrollbar(adjustment)
+ scrollbar.set_update_policy(UPDATE_DELAYED)
+ box2.pack_start(scrollbar)
+ scrollbar.show()
+
+ separator = GtkHSeparator()
+ box1.pack_start(separator, expand=FALSE)
+ separator.show()
+
+ box2 = GtkVBox(spacing=10)
+ box2.border_width(10)
+ box1.pack_start(box2, expand=FALSE)
+ box2.show()
+
+ button = GtkButton("close")
+ button.connect("clicked", win.hide)
+ box2.pack_start(button)
+ button.set_flags(CAN_DEFAULT)
+ button.grab_default()
+ button.show()
+ wins["range_controls"].show()
+
+def create_rulers(_button):
+ if not wins.has_key("rulers"):
+ win = GtkWindow()
+ wins["rulers"] = win
+ win.connect("delete_event", delete_event)
+ win.set_title("rulers")
+ win.set_usize(300, 300)
+ # these should be defined elsewhere
+ GDK_POINTER_MOTION_MASK = 1 << 2
+ GDK_POINTER_MOTION_HINT_MASK = 1 << 3
+ win.set_events(GDK_POINTER_MOTION_MASK |
+ GDK_POINTER_MOTION_HINT_MASK)
+
+ table = GtkTable(2, 3)
+ win.add(table)
+ table.show()
+
+ ruler = GtkHRuler()
+ ruler.set_range(5, 15, 0, 20)
+ ruler.set_metric(PIXELS)
+ def motion_notify(obj, event, ruler=ruler):
+ return ruler.emit("motion_notify_event", event)
+ win.connect("motion_notify_event", motion_notify)
+ table.attach(ruler, 1,2, 0,1, yoptions=FILL)
+ ruler.show()
+
+ ruler = GtkVRuler()
+ ruler.set_range(5, 15, 0, 20)
+ ruler.set_metric(PIXELS)
+ def motion_notify(obj, event, ruler=ruler):
+ return ruler.emit("motion_notify_event", event)
+ win.connect("motion_notify_event", motion_notify)
+ table.attach(ruler, 0,1, 1,2, xoptions=FILL)
+ ruler.show()
+
+ label = GtkLabel("The rulers now work!\n" +
+ "They use the new interface to\n" +
+ "gtk_signal_emit.")
+ table.attach(label, 1,2, 1,2)
+ label.show()
+
+ # XXX Finish this
+ wins["rulers"].show()
+
+def create_text(_button):
+ if not wins.has_key("text"):
+ win = GtkWindow()
+ wins["text"] = win
+ win.connect("delete_event", delete_event)
+ win.set_title("text")
+
+ box1 = GtkVBox()
+ win.add(box1)
+ box1.show()
+
+ box2 = GtkVBox(spacing=10)
+ box2.border_width(10)
+ box1.pack_start(box2)
+ box2.show()
+
+ table = GtkTable(2, 2)
+ table.set_row_spacing(0, 2)
+ table.set_col_spacing(0, 2)
+ box2.pack_start(table)
+ table.show()
+
+ text = GtkText()
+ text.set_editable(FALSE)
+ table.attach(text, 0,1, 0,1)
+ text.show()
+
+ hscrollbar = GtkHScrollbar(text.get_hadjustment())
+ table.attach(hscrollbar, 0,1, 1,2, yoptions=FILL)
+ hscrollbar.show()
+
+ vscrollbar = GtkVScrollbar(text.get_vadjustment())
+ table.attach(vscrollbar, 1,2, 0,1, xoptions=FILL)
+ vscrollbar.show()
+
+ text.freeze()
+ text.realize()
+# style = text.get_style()
+# font = style.font ; fg = style.white; bg = style.bg[
+ text.insert_defaults("some text\n")
+ text.insert_defaults("more text\n")
+ text.insert_defaults("\n")
+ text.insert_defaults("(a blank line)\n")
+ text.insert_defaults("\n")
+ text.insert_defaults("beaverloop\n")
+ text.insert_defaults("\n")
+ text.insert_defaults("Bad Acid ... Jazz!\n")
+ text.insert_defaults("\n")
+ text.insert_defaults("They all call me mellow yellow,\n")
+ text.insert_defaults("Thats 'cause I'm a mellow fellow,\n")
+ text.insert_defaults("You walk by and I'll say hello,\n")
+ text.thaw()
+
+ separator = GtkHSeparator()
+ box1.pack_start(separator, expand=FALSE)
+ separator.show()
+
+ box2 = GtkVBox(spacing=10)
+ box2.border_width(10)
+ box1.pack_start(box2, expand=FALSE)
+ box2.show()
+
+ button = GtkButton("close")
+ button.connect("clicked", win.hide)
+ box2.pack_start(button)
+ button.set_flags(CAN_DEFAULT)
+ button.grab_default()
+ button.show()
+ wins["text"].show()
+
+def create_notebook(_button):
+ if not wins.has_key("notebook"):
+ win = GtkWindow()
+ wins["notebook"] = win
+ win.connect("delete_event", delete_event)
+ win.set_title("notebook")
+
+ box1 = GtkVBox()
+ win.add(box1)
+ box1.show()
+
+ box2 = GtkVBox(spacing=10)
+ box2.border_width(10)
+ box1.pack_start(box2)
+ box2.show()
+
+ notebook = GtkNotebook()
+ notebook.set_tab_pos(POS_TOP)
+ box2.pack_start(notebook)
+ notebook.show()
+
+ for i in range(5):
+ frame = GtkFrame("Page " + str(i))
+ frame.border_width(10)
+ frame.set_usize(200, 150)
+ frame.show()
+ label = GtkLabel("Page " + str(i))
+ frame.add(label)
+ label.show()
+ label = GtkLabel("Tab " + str(i))
+ notebook.append_page(frame, label)
+ separator = GtkHSeparator()
+ box1.pack_start(separator, expand=FALSE)
+ separator.show()
+
+ box2 = GtkHBox(spacing=10)
+ box2.border_width(10)
+ box1.pack_start(box2, expand=FALSE)
+ box2.show()
+
+ button = GtkButton("close")
+ button.connect("clicked", win.hide)
+ box2.pack_start(button)
+ button.show()
+
+ button = GtkButton("next")
+ button.connect("clicked", notebook.next_page)
+ box2.pack_start(button)
+ button.show()
+
+ button = GtkButton("prev")
+ button.connect("clicked", notebook.prev_page)
+ box2.pack_start(button)
+ button.show()
+
+ def rotate_notebook(_b, note=notebook, pos=[POS_TOP]):
+ pos[0] = (pos[0] + 1) % 4
+ note.set_tab_pos(pos[0])
+
+ button = GtkButton("rotate")
+ button.connect("clicked", rotate_notebook)
+ box2.pack_start(button)
+ button.set_flags(CAN_DEFAULT)
+ button.grab_default()
+ button.show()
+ wins["notebook"].show()
+
+
+def create_panes(_button):
+ if not wins.has_key("panes"):
+ win = GtkWindow()
+ wins["panes"] = win
+ win.connect("delete_event", delete_event)
+ win.set_title("Panes")
+
+ vpaned = GtkVPaned()
+ win.add(vpaned)
+ vpaned.border_width(5)
+ vpaned.show()
+
+ hpaned = GtkHPaned()
+ vpaned.add1(hpaned)
+
+ frame = GtkFrame()
+ frame.set_shadow_type(SHADOW_IN)
+ frame.set_usize(60, 60)
+ hpaned.add1(frame)
+ frame.show()
+
+ frame = GtkFrame()
+ frame.set_shadow_type(SHADOW_IN)
+ frame.set_usize(80, 60)
+ hpaned.add2(frame)
+ frame.show()
+
+ hpaned.show()
+
+ box2 = GtkVBox(spacing=10)
+ box2.border_width(10)
+ vpaned.add2(box2)
+ box2.show()
+
+ button = GtkButton("close")
+ button.connect("clicked", win.hide)
+ box2.pack_start(button)
+ button.set_flags(CAN_DEFAULT)
+ button.grab_default()
+ button.show()
+ wins["panes"].show()
+
+def create_dnd(_button):
+ if not wins.has_key("dnd"):
+ # note that these two functions don't use any global variables
+ # to communicate. In fact, try openning two copies of
+ # testgtk.py (or the C version) and drag between them.
+ def dnd_drop(button, event):
+ msg = "Drop data of type %s was:\n\n%s" % \
+ (event.data_type, event.data)
+ GtkExtra.message_box("Drop", msg,
+ ("Continue with life in\n" +
+ "spite of this oppression",))
+ def dnd_drag_request(button, event):
+ dnd_string = "Bill Gates demands royalties for\n" + \
+ "your use of his innovation."
+ button.dnd_data_set(event, dnd_string)
+ win = GtkWindow(WINDOW_TOPLEVEL)
+ wins["dnd"] = win
+ win.connect("delete_event", lambda win,_e: win.hide())
+ win.set_title("Drag -N- Drop")
+
+ box1 = GtkVBox()
+ win.add(box1)
+ box1.show()
+
+ box2 = GtkHBox(spacing=5)
+ box2.border_width(10)
+ box1.pack_start(box2)
+ box2.show()
+
+ frame = GtkFrame("Drag")
+ box2.pack_start(frame)
+ frame.show()
+
+ box3 = GtkVBox(spacing=5)
+ box3.border_width(5)
+ frame.add(box3)
+ box3.show()
+
+ button = GtkButton("Drag me!")
+ box3.pack_start(button)
+ button.show()
+ button.realize()
+ button.connect("drag_request_event", dnd_drag_request)
+ button.dnd_drag_set(TRUE, ['text/plain'])
+
+ frame = GtkFrame("Drop")
+ box2.pack_start(frame)
+ frame.show()
+
+ box3 = GtkVBox(spacing=5)
+ box3.border_width(5)
+ frame.add(box3)
+ box3.show()
+
+ button = GtkButton("To")
+ box3.pack_start(button)
+ button.show()
+ button.realize()
+ button.connect("drop_data_available_event", dnd_drop)
+ button.dnd_drop_set(TRUE, ['text/plain'], FALSE)
+
+ separator = GtkHSeparator()
+ box1.pack_start(separator, expand=FALSE)
+ separator.show()
+
+ box2 = GtkVBox(spacing=10)
+ box2.border_width(10)
+ box1.pack_start(box2, expand=FALSE)
+ box2.show()
+
+ button = GtkButton("close")
+ button.connect("clicked", win.hide)
+ box2.pack_start(button)
+ button.set_flags(CAN_DEFAULT)
+ button.grab_default()
+ button.show()
+ wins['dnd'].show()
+
+def create_progress_bar(_button):
+ if not wins.has_key("progress_bar"):
+ win = GtkDialog()
+ wins["progress_bar"] = win
+ win.set_title("dialog")
+
+ vbox = GtkVBox(spacing=5)
+ vbox.border_width(10)
+ win.vbox.pack_start(vbox)
+ vbox.show()
+
+ label = GtkLabel("progress...")
+ label.set_alignment(0, 0.5)
+ vbox.pack_start(label, expand=FALSE)
+ label.show()
+
+ pbar = GtkProgressBar()
+ pbar.set_usize(200, 20)
+ vbox.pack_start(pbar)
+ pbar.show()
+
+ def timeout(pbar=pbar, pcnt=[0]):
+ pcnt[0] = (pcnt[0] + 0.02) % 1.0
+ pbar.update(pcnt[0])
+ return TRUE
+
+ win.func = [timeout, 0]
+
+ def killit(arg1=None, arg2=None, tid=win.func, win=win):
+ timeout_remove(tid[1])
+ win.hide()
+ win.connect("destroy", killit)
+ win.connect("delete_event", killit)
+
+ button = GtkButton("close")
+ button.connect("clicked", killit)
+ win.action_area.pack_start(button)
+ button.set_flags(CAN_DEFAULT)
+ button.grab_default()
+ button.show()
+ win = wins["progress_bar"]
+ win.show()
+ win.func[1] = timeout_add(100, win.func[0])
+
+def create_gamma_curve(_button):
+ if not wins.has_key("gamma_curve"):
+ win = GtkWindow()
+ wins["gamma_curve"] = win
+ win.connect("delete_event", lambda _w, _e, win=win: win.hide())
+ win.set_title("test")
+ win.set_usize(200, 150)
+
+ curve = GtkGammaCurve()
+ win.add(curve)
+ curve.realize()
+ curve.show()
+ wins["gamma_curve"].show()
+
+def create_timeout_test(_button):
+ if not wins.has_key("timeout_test"):
+ win = GtkDialog()
+ wins["timeout_test"] = win
+ win.connect("delete_event", delete_event)
+ win.set_title("Timeout Test")
+
+ label = GtkLabel("count: 0")
+ label.set_padding(10, 10)
+ win.vbox.pack_start(label)
+ label.show()
+
+ func = [None, 0]
+ def timeout_test(label=label, count=[0]):
+ count[0] = count[0] + 1
+ label.set("count: " + str(count[0]))
+ return TRUE
+
+ func = [timeout_test, 0]
+ def start_timeout_test(_button, func=func):
+ if not func[1]:
+ func[1] = timeout_add(100, func[0])
+ def stop_timeout_test(_button, func=func):
+ if func[1]:
+ timeout_remove(func[1])
+ func[1] = 0
+
+ button = GtkButton("close")
+ button.connect("clicked", win.hide)
+ win.action_area.pack_start(button)
+ button.set_flags(CAN_DEFAULT)
+ button.grab_default()
+ button.show()
+
+ button = GtkButton("start")
+ button.connect("clicked", start_timeout_test)
+ win.action_area.pack_start(button)
+ button.show()
+
+ button = GtkButton("stop")
+ button.connect("clicked", stop_timeout_test)
+ win.action_area.pack_start(button)
+ button.show()
+ wins["timeout_test"].show()
+
+def create_idle_test(_button):
+ if not wins.has_key("idle_test"):
+ win = GtkDialog()
+ wins["idle_test"] = win
+ win.connect("delete_event", delete_event)
+ win.set_title("Idle Test")
+
+ label = GtkLabel("count: 0")
+ label.set_padding(10, 10)
+ win.vbox.pack_start(label)
+ label.show()
+
+ def idle_test(label=label, count=[0]):
+ count[0] = count[0] + 1
+ label.set("count: " + str(count[0]))
+ return TRUE
+
+ win.func = [idle_test, 0]
+ def start_idle_test(_button, func=win.func):
+ if not func[1]:
+ func[1] = idle_add(func[0])
+ def stop_idle_test(_button, func=win.func):
+ if func[1]:
+ idle_remove(func[1])
+ func[1] = 0
+
+ button = GtkButton("close")
+ button.connect("clicked", win.hide)
+ win.action_area.pack_start(button)
+ button.set_flags(CAN_DEFAULT)
+ button.grab_default()
+ button.show()
+
+ button = GtkButton("start")
+ button.connect("clicked", start_idle_test)
+ win.action_area.pack_start(button)
+ button.show()
+
+ button = GtkButton("stop")
+ button.connect("clicked", stop_idle_test)
+ win.action_area.pack_start(button)
+ button.show()
+ wins["idle_test"].show()
+
+def do_exit(button):
+ mainquit()
+
+def create_main_window():
+ buttons = {
+ "buttons": create_buttons,
+ "toggle buttons": create_toggle_buttons,
+ "check buttons": create_check_buttons,
+ "radio buttons": create_radio_buttons,
+ "button box": create_button_box,
+ "toolbar": create_toolbar,
+ "handle box": create_handle_box,
+ "reparent": create_reparent,
+ "pixmap": create_pixmap,
+ "tooltips": create_tooltips,
+ "menus": create_menus,
+ "scrolled windows": create_scrolled_windows,
+ "drawing areas": None,
+ "entry": create_entry,
+ "list": create_list,
+ "clist": create_clist,
+ "color selection": create_color_selection,
+ "file selection": create_file_selection,
+ "dialog": create_dialog,
+ "miscellaneous": None,
+ "range controls": create_range_controls,
+ "rulers": create_rulers,
+ "text": create_text,
+ "notebook": create_notebook,
+ "panes": create_panes,
+ "shapes": None, #create_shapes,
+ "dnd": create_dnd,
+ "progress bar": create_progress_bar,
+ "preview color": None, #create_color_preview,
+ "preview gray": None, #create_gray_preview,
+ "gamma curve": create_gamma_curve,
+ "test scrolling": None, #creaate_scroll_text,
+ "test selection": None, #create_selection_test,
+ "test timeout": create_timeout_test,
+ "test idle": create_idle_test,
+ "test": None, #create_test
+ "status bar": create_statusbar_test,
+ }
+ win = GtkWindow()
+ win.set_name("main window")
+ win.set_usize(200, 400)
+ win.set_uposition(20, 20)
+ win.connect("destroy", mainquit)
+ win.connect("delete_event", mainquit)
+ win.set_title("gtktest")
+ box1 = GtkVBox(FALSE, 0)
+ win.add(box1)
+ box1.show()
+ scrolled_window = GtkScrolledWindow()
+ scrolled_window.border_width(10)
+ scrolled_window.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC)
+ box1.pack_start(scrolled_window)
+ scrolled_window.show()
+ box2 = GtkVBox()
+ box2.border_width(10)
+ scrolled_window.add(box2)
+ box2.show()
+ k = buttons.keys()
+ k.sort()
+ for i in k:
+ button = GtkButton(i)
+ if buttons[i]:
+ button.connect("clicked", buttons[i])
+ else:
+ button.set_sensitive(FALSE)
+ box2.pack_start(button)
+ button.show()
+ separator = GtkHSeparator()
+ box1.pack_start(separator, expand=FALSE)
+ separator.show()
+ box2 = GtkVBox(spacing=10)
+ box2.border_width(10)
+ box1.pack_start(box2, expand=FALSE)
+ box2.show()
+ button = GtkButton("close")
+ button.connect("clicked", do_exit)
+ button.set_flags(CAN_DEFAULT)
+ box2.pack_start(button)
+ button.grab_default()
+ button.show()
+ win.show()
+
+def main():
+ rc_parse("testgtkrc")
+ create_main_window()
+ mainloop()
+
+if __name__ == '__main__': main()
diff --git a/examples/testgtk/testgtkrc b/examples/testgtk/testgtkrc
new file mode 100644
index 00000000..68e5578a
--- /dev/null
+++ b/examples/testgtk/testgtkrc
@@ -0,0 +1,69 @@
+# pixmap_path "<dir 1>:<dir 2>:<dir 3>:..."
+#
+# style <name> [= <name>]
+# {
+# <option>
+# }
+#
+# widget <widget_set> style <style_name>
+# widget_class <widget_class_set> style <style_name>
+
+pixmap_path "."
+
+style "window"
+{
+# bg_pixmap[NORMAL] = "warning.xpm"
+}
+
+style "scale"
+{
+ fg[NORMAL] = { 1.0, 0, 0 }
+ bg_pixmap[NORMAL] = "<parent>"
+}
+
+style "button"
+{
+ fg[PRELIGHT] = { 1.0, 1.0, 1.0 }
+ bg[PRELIGHT] = { 0, 0, 0.75 }
+}
+
+style "main_button" = "button"
+{
+ font = "-adobe-helvetica-medium-r-normal--*-100-*-*-*-*-*-*"
+ bg[PRELIGHT] = { 0.75, 0, 0 }
+}
+
+style "toggle_button" = "button"
+{
+ fg[NORMAL] = { 1.0, 0, 0 }
+ fg[ACTIVE] = { 1.0, 0, 0 }
+ bg_pixmap[NORMAL] = "<parent>"
+}
+
+style "text"
+{
+ fg[NORMAL] = { 1.0, 1.0, 1.0 }
+ base[NORMAL] = { 0, 0, 0 }
+}
+
+style "ruler"
+{
+ font = "-adobe-helvetica-medium-r-normal--*-80-*-*-*-*-*-*"
+}
+
+style "curve"
+{
+ fg[NORMAL] = { 58000, 0, 0 } # red
+}
+
+widget_class "GtkWindow" style "window"
+widget_class "GtkDialog" style "window"
+widget_class "GtkFileSelection" style "window"
+widget_class "*Gtk*Scale" style "scale"
+widget_class "*GtkCheckButton*" style "toggle_button"
+widget_class "*GtkRadioButton*" style "toggle_button"
+widget_class "*GtkButton*" style "button"
+widget_class "*Ruler" style "ruler"
+widget_class "*GtkText" style "text"
+widget "main window.*GtkButton*" style "main_button"
+widget "*GtkCurve" style "curve"