File: gdl_combo_button.py

package info (click to toggle)
gnome-python-extras 2.14.3-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 2,756 kB
  • ctags: 731
  • sloc: sh: 8,856; ansic: 5,011; xml: 1,319; python: 725; makefile: 415
file content (88 lines) | stat: -rw-r--r-- 2,583 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/python

#   Copyright (C) 2007 - Gian Mario Tagliaretti <g.tagliaretti@parafernalia.org>
#   
#   This program is free software; you can redistribute it and/or
#   modify it under the terms of the GNU General Public License
#   as published by the Free Software Foundation;
#   
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#   
#   You should have received a copy of the GNU Lesser General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

import pygtk
pygtk.require("2.0")
import gdl
import gtk

def combo_button_activate_default_cb (combo):
    print "combo_button_activate_default_cb"

window = gtk.Window (gtk.WINDOW_TOPLEVEL)
window.connect ("delete_event", gtk.main_quit)
window.set_title ("Combo button test")
window.set_resizable (False)

hbox = gtk.HBox (False, 0)
window.add (hbox)

combo = gtk.Button (None, gtk.STOCK_OPEN)
combo.set_relief (gtk.RELIEF_NONE)
hbox.pack_start (combo, False, False, 0)

menu = gtk.Menu ()
menuitem = gtk.ImageMenuItem (gtk.STOCK_OPEN, None)
menu.append (menuitem)
menuitem = gtk.ImageMenuItem (gtk.STOCK_SAVE, None)
menu.append (menuitem)
menu.show_all ()

combo = gdl.ComboButton ()
combo.set_label ("Run")
combo.set_menu (menu)

icon = combo.render_icon (gtk.STOCK_EXECUTE, gtk.ICON_SIZE_LARGE_TOOLBAR)
combo.set_icon (icon)
hbox.pack_start (combo, False, False, 0)

combo.connect ("activate_default", combo_button_activate_default_cb)

combo = gtk.Button (None, gtk.STOCK_SAVE)
combo.set_relief (gtk.RELIEF_NONE)
hbox.pack_start (combo, False, False, 0)

menu = gtk.Menu ()
menuitem = gtk.ImageMenuItem (gtk.STOCK_OPEN, None)
menu.append (menuitem)
menuitem = gtk.ImageMenuItem (gtk.STOCK_SAVE, None)
menu.append (menuitem)
menu.show_all ()

combo = gdl.ComboButton ()
combo.set_label ("Open")
combo.set_menu (menu)

icon = combo.render_icon (gtk.STOCK_OPEN, gtk.ICON_SIZE_LARGE_TOOLBAR)
combo.set_icon (icon)
combo.set_sensitive (False)
hbox.pack_start (combo, False, False, 0)

combo.connect ("activate_default", combo_button_activate_default_cb)

menu = gtk.Menu ()
combo = gdl.ComboButton ()
combo.set_label ("Open")
combo.set_menu (menu)

icon = combo.render_icon (gtk.STOCK_OPEN, gtk.ICON_SIZE_LARGE_TOOLBAR)
combo.set_icon (icon)
hbox.pack_start (combo, False, False, 0)

window.show_all ()

gtk.main ()