Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManuel Kaufmann <humitos@gmail.com>2012-10-16 12:50:49 (GMT)
committer Manuel Kaufmann <humitos@gmail.com>2012-10-16 12:50:49 (GMT)
commit3be4d00b0f3177e2814ee9581df24564cb6dc39f (patch)
treedbf90b692eaa89cd315ebe31fc4e5ec541875a88
parentd3ad60372be0598b5a17e3a700533202eceabde8 (diff)
Some Examples
-rw-r--r--examples/gestures_new.py55
-rw-r--r--examples/gtk2-app-example.py41
2 files changed, 96 insertions, 0 deletions
diff --git a/examples/gestures_new.py b/examples/gestures_new.py
new file mode 100644
index 0000000..0eca5a6
--- /dev/null
+++ b/examples/gestures_new.py
@@ -0,0 +1,55 @@
+from gi.repository import WebKit
+from gi.repository import Gtk
+from gi.repository import Gdk
+from gi.repository import SugarGestures
+
+def _destroy_cb(widget, data=None):
+ Gtk.main_quit()
+
+def _swipe_ended_cb(controller, direction):
+ print direction
+ if direction == SugarGestures.SwipeDirection.UP:
+ print '==> UP'
+ elif direction == SugarGestures.SwipeDirection.DOWN:
+ print '==> DOWN'
+ elif direction == SugarGestures.SwipeDirection.RIGHT:
+ print '==> RIGHT'
+ elif direction == SugarGestures.SwipeDirection.LEFT:
+ print '==> LEFT'
+
+def _lp_began_cb(controller):
+ print '===> lp began'
+
+def _scale_changed_cb(controller, scale):
+ print '===> zoom changed scale=%s', scale
+
+def _angle_changed_cb(controller, angle, diff):
+ print '===> rotate changed: ', angle, diff
+
+
+window = Gtk.Window()
+window.set_default_size(800, 640)
+window.connect("destroy", _destroy_cb)
+window.add_events(Gdk.EventMask.BUTTON_PRESS_MASK |
+ Gdk.EventMask.BUTTON_RELEASE_MASK |
+ Gdk.EventMask.POINTER_MOTION_MASK |
+ Gdk.EventMask.TOUCH_MASK)
+
+zoom = SugarGestures.ZoomController()
+zoom.connect('scale-changed', _scale_changed_cb)
+zoom.attach(window, SugarGestures.EventControllerFlags.NONE)
+
+rotate = SugarGestures.RotateController()
+rotate.connect('angle-changed', _angle_changed_cb)
+rotate.attach(window, SugarGestures.EventControllerFlags.NONE)
+
+swipe = SugarGestures.SwipeController()
+swipe.connect('swipe-ended', _swipe_ended_cb)
+swipe.attach(window, SugarGestures.EventControllerFlags.NONE)
+
+lp = SugarGestures.LongPressController(trigger_delay=1000)
+lp.connect('began', _lp_began_cb)
+lp.attach(window, SugarGestures.EventControllerFlags.NONE)
+
+window.show()
+Gtk.main()
diff --git a/examples/gtk2-app-example.py b/examples/gtk2-app-example.py
new file mode 100644
index 0000000..6c31046
--- /dev/null
+++ b/examples/gtk2-app-example.py
@@ -0,0 +1,41 @@
+#!/usr/bin/env python
+
+# example helloworld.py
+# http://www.pygtk.org/pygtk2tutorial/examples/helloworld.py
+
+import pygtk
+pygtk.require('2.0')
+import gtk
+
+
+class Test(object):
+
+ def destroy(self, widget, data=None):
+ gtk.main_quit()
+
+ def __init__(self):
+ # create a new window
+ self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
+ self.window.resize(250, 250)
+
+ self.window.connect("destroy", self.destroy)
+
+ # Sets the border width of the window.
+ self.window.set_border_width(10)
+
+ self.label = gtk.Label('')
+ self.label.set_use_markup(True)
+ self.label.set_markup('<span foreground="blue" size="20000">Blue text</span> is <i>cool</i>!')
+
+ self.window.add(self.label)
+
+ # and the window
+ self.window.show_all()
+
+ def main(self):
+ gtk.main()
+
+
+if __name__ == "__main__":
+ test = Test()
+ test.main()