Ticket #3831: test.py

File test.py, 908 bytes (added by manuq, 10 years ago)

Isolated example using gtk_widget_add_tick_callback ()

Line 
1from gi.repository import Gtk
2from gi.repository import Gdk
3
4x = 0
5
6class FrameWindow(Gtk.Window):
7    def __init__(self):
8        Gtk.Window.__init__(self)
9        self.set_has_resize_grip(False)
10        self.resize(100, Gdk.Screen.height())
11        self.set_decorated(False)
12
13    def do_draw(self, cr):
14        # Draw the inner border as a rectangle
15        r, g, b, a = 0, 0, 0, 1
16        cr.set_source_rgba(r, g, b, a)
17
18        allocation = self.get_allocation()
19        cr.rectangle(allocation.x, allocation.y,
20                     allocation.width, allocation.height)
21        cr.fill()
22
23
24window = Gtk.Window()
25window.connect("delete-event", Gtk.main_quit)
26window.show()
27
28frame_panel = FrameWindow()
29frame_panel.show()
30
31def tick_cb(widget, frame_clock, bla):
32    global x
33    x += 1
34    widget.move(x, 0)
35
36    return True
37
38frame_panel.move(x, 0)
39frame_panel.add_tick_callback(tick_cb, None)
40
41Gtk.main()