9
window.set_default_size(700, 350)
11
window.connect("delete_event", on_delete_event)
13
scrolled_win = gtk.ScrolledWindow()
14
scrolled_win.set_shadow_type(gtk.SHADOW_IN)
16
window.add(scrolled_win)
18
canvas = goocanvas.Canvas()
19
canvas.set_size_request(700, 350)
20
canvas.set_bounds(0, 0, 1000, 1000)
22
scrolled_win.add(canvas)
24
root = canvas.get_root_item()
26
# Create a Linear Patter with cairo
27
linear = cairo.LinearGradient(50, 50, 300, 300)
28
linear.add_color_stop_rgba(0.0, 1, 1, 1, 0)
29
linear.add_color_stop_rgba(0.25, 0, 1, 0, 0.5)
30
linear.add_color_stop_rgba(0.50, 1, 1, 1, 0)
31
linear.add_color_stop_rgba(0.75, 0, 0, 1, 0.5)
32
linear.add_color_stop_rgba(1.0, 1, 1, 1, 0)
34
# Create a rect to be filled with the linear gradient
35
item = goocanvas.Rect(x=50, y=50, width=250, height=250,
40
root.add_child(item, 0)
42
item.connect("button-press-event", on_rect_button_press)
44
item = goocanvas.Text(parent=root,
45
text="Linear Gradient",
47
anchor=gtk.ANCHOR_CENTER,
49
item.rotate(315, 175, 175)
51
# Create a Radial Patter with cairo
52
radial = cairo.RadialGradient(450, 150, 15, 600, 250, 55)
53
radial.add_color_stop_rgb(0, 1.0, 0.8, 0.8)
54
radial.add_color_stop_rgb(0.50, 0.9, 0.5, 0.0)
55
radial.add_color_stop_rgb(1, 0.9, 0.0, 0.0)
58
# Create a rect to be filled with the radial gradient
59
item = goocanvas.Rect(parent=root,
60
x=400, y=50, width=250, height=250,
66
item.connect("button-press-event", on_rect_button_press)
68
item = goocanvas.Text(parent=root,
69
text="Radial Gradient",
71
anchor=gtk.ANCHOR_CENTER,
73
item.rotate(315, 525, 175)
77
## This handles button presses in item views. We simply output a message to
79
def on_rect_button_press (view, target, event):
80
target.set_simple_transform(50, 50 , 1, 0)
81
print "rect item received button press event"
85
## This is our handler for the "delete-event" signal of the window, which
86
## is emitted when the 'x' close button is clicked. We just exit here. */
87
def on_delete_event(window, event):
90
if __name__ == "__main__":