summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorJohan Dahlin <johan@gnome.org>2012-03-22 10:38:59 -0300
committerJohan Dahlin <jdahlin@litl.com>2012-03-22 11:16:45 -0300
commit725483a5dc36739dc7836716b5d6d48091564bf8 (patch)
tree5de6a9559febf83cf8119b4673257aa6d3b5570d /examples
parent917275d4aa81db39ccaca34fa514032fb80a3187 (diff)
downloadpygobject-725483a5dc36739dc7836716b5d6d48091564bf8.tar.gz
PEP8: run via --fix from craigds fork
https://bugzilla.gnome.org/show_bug.cgi?id=672627
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/cairo-demo.py57
-rw-r--r--examples/option.py1
-rw-r--r--examples/properties.py1
-rw-r--r--examples/signal.py4
4 files changed, 38 insertions, 25 deletions
diff --git a/examples/cairo-demo.py b/examples/cairo-demo.py
index 1cc69bf1..5f5bf6b1 100755
--- a/examples/cairo-demo.py
+++ b/examples/cairo-demo.py
@@ -8,39 +8,44 @@ from gi.repository import Gtk
SIZE = 30
+
def triangle(ctx):
ctx.move_to(SIZE, 0)
- ctx.rel_line_to(SIZE, 2*SIZE)
- ctx.rel_line_to(-2*SIZE, 0)
+ ctx.rel_line_to(SIZE, 2 * SIZE)
+ ctx.rel_line_to(-2 * SIZE, 0)
ctx.close_path()
+
def square(ctx):
ctx.move_to(0, 0)
- ctx.rel_line_to(2*SIZE, 0)
- ctx.rel_line_to(0, 2*SIZE)
- ctx.rel_line_to(-2*SIZE, 0)
+ ctx.rel_line_to(2 * SIZE, 0)
+ ctx.rel_line_to(0, 2 * SIZE)
+ ctx.rel_line_to(-2 * SIZE, 0)
ctx.close_path()
+
def bowtie(ctx):
ctx.move_to(0, 0)
- ctx.rel_line_to(2*SIZE, 2*SIZE)
- ctx.rel_line_to(-2*SIZE, 0)
- ctx.rel_line_to(2*SIZE, -2*SIZE)
+ ctx.rel_line_to(2 * SIZE, 2 * SIZE)
+ ctx.rel_line_to(-2 * SIZE, 0)
+ ctx.rel_line_to(2 * SIZE, -2 * SIZE)
ctx.close_path()
+
def inf(ctx):
ctx.move_to(0, SIZE)
- ctx.rel_curve_to(0,SIZE, SIZE,SIZE, 2*SIZE,0)
- ctx.rel_curve_to(SIZE,-SIZE, 2*SIZE,-SIZE, 2*SIZE,0)
- ctx.rel_curve_to(0,SIZE, -SIZE,SIZE, -2*SIZE,0)
- ctx.rel_curve_to(-SIZE,-SIZE, -2*SIZE,-SIZE, -2*SIZE,0)
+ ctx.rel_curve_to(0, SIZE, SIZE, SIZE, 2*SIZE, 0)
+ ctx.rel_curve_to(SIZE, -SIZE, 2 *SIZE, -SIZE, 2*SIZE, 0)
+ ctx.rel_curve_to(0, SIZE, -SIZE, SIZE, - 2*SIZE, 0)
+ ctx.rel_curve_to(-SIZE, -SIZE, - 2 *SIZE, -SIZE, - 2*SIZE, 0)
ctx.close_path()
+
def draw_shapes(ctx, x, y, fill):
ctx.save()
ctx.new_path()
- ctx.translate(x+SIZE, y+SIZE)
+ ctx.translate(x + SIZE, y + SIZE)
bowtie(ctx)
if fill:
ctx.fill()
@@ -48,7 +53,7 @@ def draw_shapes(ctx, x, y, fill):
ctx.stroke()
ctx.new_path()
- ctx.translate(3*SIZE, 0)
+ ctx.translate(3 * SIZE, 0)
square(ctx)
if fill:
ctx.fill()
@@ -56,7 +61,7 @@ def draw_shapes(ctx, x, y, fill):
ctx.stroke()
ctx.new_path()
- ctx.translate(3*SIZE, 0)
+ ctx.translate(3 * SIZE, 0)
triangle(ctx)
if fill:
ctx.fill()
@@ -64,7 +69,7 @@ def draw_shapes(ctx, x, y, fill):
ctx.stroke()
ctx.new_path()
- ctx.translate(3*SIZE, 0)
+ ctx.translate(3 * SIZE, 0)
inf(ctx)
if fill:
ctx.fill()
@@ -73,12 +78,15 @@ def draw_shapes(ctx, x, y, fill):
ctx.restore()
+
def fill_shapes(ctx, x, y):
draw_shapes(ctx, x, y, True)
+
def stroke_shapes(ctx, x, y):
draw_shapes(ctx, x, y, False)
+
def draw(da, ctx):
ctx.set_source_rgb(0, 0, 0)
@@ -86,24 +94,25 @@ def draw(da, ctx):
ctx.set_tolerance(0.1)
ctx.set_line_join(cairo.LINE_JOIN_ROUND)
- ctx.set_dash([SIZE/4.0, SIZE/4.0], 0)
+ ctx.set_dash([SIZE / 4.0, SIZE / 4.0], 0)
stroke_shapes(ctx, 0, 0)
ctx.set_dash([], 0)
- stroke_shapes(ctx, 0, 3*SIZE)
+ stroke_shapes(ctx, 0, 3 * SIZE)
ctx.set_line_join(cairo.LINE_JOIN_BEVEL)
- stroke_shapes(ctx, 0, 6*SIZE)
+ stroke_shapes(ctx, 0, 6 * SIZE)
ctx.set_line_join(cairo.LINE_JOIN_MITER)
- stroke_shapes(ctx, 0, 9*SIZE)
+ stroke_shapes(ctx, 0, 9 * SIZE)
- fill_shapes(ctx, 0, 12*SIZE)
+ fill_shapes(ctx, 0, 12 * SIZE)
ctx.set_line_join(cairo.LINE_JOIN_BEVEL)
- fill_shapes(ctx, 0, 15*SIZE)
- ctx.set_source_rgb(1,0,0)
- stroke_shapes(ctx, 0, 15*SIZE)
+ fill_shapes(ctx, 0, 15 * SIZE)
+ ctx.set_source_rgb(1, 0, 0)
+ stroke_shapes(ctx, 0, 15 * SIZE)
+
def main():
win = Gtk.Window()
diff --git a/examples/option.py b/examples/option.py
index c05d0a8d..4c616021 100644
--- a/examples/option.py
+++ b/examples/option.py
@@ -10,7 +10,6 @@ group = OptionGroup("example", "OptionGroup Example", "Shows all example options
dest="example",
help="An example option."),
])
-
parser = OptionParser("NAMES ...",
description="A simple gobject.option example.",
option_list=[
diff --git a/examples/properties.py b/examples/properties.py
index eebfb163..465b3c3c 100644
--- a/examples/properties.py
+++ b/examples/properties.py
@@ -1,5 +1,6 @@
from gi.repository import GObject
+
class MyObject(GObject.GObject):
foo = GObject.Property(type=str, default='bar')
diff --git a/examples/signal.py b/examples/signal.py
index d1b7357b..057addae 100644
--- a/examples/signal.py
+++ b/examples/signal.py
@@ -1,18 +1,22 @@
from gi.repository import GObject
+
class C(GObject.GObject):
__gsignals__ = {
'my_signal': (GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE,
(GObject.TYPE_INT,))
}
+
def do_my_signal(self, arg):
print "C: class closure for `my_signal' called with argument", arg
+
class D(C):
def do_my_signal(self, arg):
print "D: class closure for `my_signal' called. Chaining up to C"
C.do_my_signal(self, arg)
+
def my_signal_handler(object, arg, *extra):
print "handler for `my_signal' called with argument", arg, \
"and extra args", extra