1 #!/usr/bin/env python
2
3 # example arrow.py
4
5 import gtk
6
7 # Create an Arrow widget with the specified parameters
8 # and pack it into a button
9 def create_arrow_button(arrow_type, shadow_type):
10 button = gtk.GtkButton();
11 arrow = gtk.GtkArrow(arrow_type, shadow_type);
12 button.add(arrow)
13 button.show()
14 arrow.show()
15 return button
16
17 class Arrows:
18 def __init__(self):
19 # Create a new window
20 window = gtk.GtkWindow(gtk.WINDOW_TOPLEVEL)
21
22 window.set_title("Arrow Buttons")
23
24 # It's a good idea to do this for all windows.
25 window.connect("destroy", gtk.mainquit)
26
27 # Sets the border width of the window.
28 window.set_border_width(10)
29
30 # Create a box to hold the arrows/buttons
31 box = gtk.GtkHBox(gtk.FALSE, 0)
32 box.set_border_width(2)
33 window.add(box)
34
35 # Pack and show all our widgets
36 box.show()
37
38 button = create_arrow_button(gtk.ARROW_UP, gtk.SHADOW_IN)
39 box.pack_start(button, gtk.FALSE, gtk.FALSE, 3)
40
41 button = create_arrow_button(gtk.ARROW_DOWN, gtk.SHADOW_OUT)
42 box.pack_start(button, gtk.FALSE, gtk.FALSE, 3)
43
44 button = create_arrow_button(gtk.ARROW_LEFT, gtk.SHADOW_ETCHED_IN)
45 box.pack_start(button, gtk.FALSE, gtk.FALSE, 3)
46
47 button = create_arrow_button(gtk.ARROW_RIGHT, gtk.SHADOW_ETCHED_OUT)
48 box.pack_start(button, gtk.FALSE, gtk.FALSE, 3)
49
50 window.show()
51
52 def main():
53 gtk.mainloop()
54 return 0
55
56 if __name__ == "__main__":
57 Arrows()
58 main()
|