[gegl-qt] Python: Add GeglQt::NodeViewOptions to bindings



commit 8cec78cba30c0b224340921d0830100215b8edbf
Author: Jon Nordby <jononor gmail com>
Date:   Thu Sep 22 22:34:14 2011 +0200

    Python: Add GeglQt::NodeViewOptions to bindings

 examples/python-nodeviewoptions.py |   45 ++++++++++++++++++++++++++++++++++++
 pygegl-qt/typesystem_gegl-qt.xml   |    4 +++
 2 files changed, 49 insertions(+), 0 deletions(-)
---
diff --git a/examples/python-nodeviewoptions.py b/examples/python-nodeviewoptions.py
new file mode 100644
index 0000000..1b24916
--- /dev/null
+++ b/examples/python-nodeviewoptions.py
@@ -0,0 +1,45 @@
+#!/usr/bin/env python2
+
+import sys
+
+import gobject
+import gi
+from gi.repository import Gegl
+
+from PySide.QtCore import *
+from PySide.QtGui import *
+
+from geglqt import GeglQt
+
+graph_xml = """
+<gegl>
+  <gegl:load path='%s'/>
+</gegl>"""
+
+if __name__ == '__main__':
+
+    app = QApplication(sys.argv)
+
+    if len(sys.argv) != 2:
+        print "usage: %s FILE" % sys.argv[0]
+        exit(1)
+
+    file_path = sys.argv[1]
+
+    Gegl.init(0,"")
+    graph = Gegl.Node.new_from_xml(graph_xml % file_path, "/")
+    node = graph.get_children()[-1]
+
+    view = GeglQt.NodeViewWidget()
+
+    view.options().setTranslationX(10)
+    view.options().setTranslationY(10)
+
+    view.options().setAutoScalePolicy(GeglQt.NodeViewOptions.AutoScaleToView)
+    view.options().setAutoCenterPolicy(GeglQt.NodeViewOptions.AutoCenterEnabled)
+
+    view.setInputNode(node)
+    view.show()
+
+    app.exec_()
+    sys.exit()
diff --git a/pygegl-qt/typesystem_gegl-qt.xml b/pygegl-qt/typesystem_gegl-qt.xml
index ec83cb9..231a76e 100644
--- a/pygegl-qt/typesystem_gegl-qt.xml
+++ b/pygegl-qt/typesystem_gegl-qt.xml
@@ -12,6 +12,10 @@
         <object-type name="NodeViewWidget" />
         <object-type name="NodeViewGraphicsWidget" />
         <object-type name="NodeViewDeclarativeItem" />
+        <object-type name="NodeViewOptions" >
+            <enum-type name="AutoScale"/>
+            <enum-type name="AutoCenter"/>
+        </object-type>
     </namespace-type>
 </typesystem>
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]