/usr/share/pyshared/fltk/test/menubar.py is in python-fltk 1.3.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 | #
# "$Id: menubar.py 282 2006-11-13 14:59:59Z andreasheld $"
#
# Menubar test program for pyFLTK the Python bindings
# for the Fast Light Tool Kit (FLTK).
#
# FLTK copyright 1998-1999 by Bill Spitzak and others.
# pyFLTK copyright 2003 by Andreas Held and others.
#
# This library is free software you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation either
# version 2 of the License, or (at your option) any later version.
#
# This library 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
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with this library if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA.
#
# Please report all bugs and problems to "pyfltk-user@lists.sourceforge.net".
#
from fltk import *
import sys
hugemenu = []
def window_cb(win):
print "window callback called!"
win.hide()
def test_cb(menu):
m = menu.mvalue()
if (not m):
print "menu.mvalue()=NULL"
else:
if (m.shortcut()):
print "%s - %s" % ( m.label(), fl_shortcut_label(m.shortcut()) )
else:
print m.label()
def quit_cb(ptr, data):
sys.exit(0)
# hack alert:
# nm - create Fl_Menu_Item from initializer list
def nm(list):
m = Fl_Menu_Item()
try:
if not list[0]:
m.text = Null
else:
m.text = list[0]
m.shortcut_ = list[1]
m.callback_ = list[2]
m.user_data = list[3]
m.flags = list[4]
except:
pass
return m
pulldown = []
pulldown.append(nm(("Red", FL_ALT+ord('r'))))
pulldown.append(nm(("Green", FL_ALT+ord('g'))))
pulldown.append(nm(("Blue", FL_ALT+ord('b'))))
pulldown.append(nm(("Strange", FL_ALT+ord('s'))))
pulldown.append(nm(("&Charm", FL_ALT+ord('c'))))
pulldown.append(nm(("Truth", FL_ALT+ord('t'))))
pulldown.append(nm(("Beauty", FL_ALT+ord('b'))))
pulldown.append(nm((0,)))
WIDTH=600
menus = [0,0,0,0]
# turn MicroSoft style on/off
def button_cb(btn):
if (btn.value() == 0):
for i in range(4):
print i
menus[i].down_box(FL_FLAT_BOX)
menus[i].selection_color(137)
menus[i].textfont(FL_HELVETICA)
else:
for i in range(4):
menus[i].down_box(FL_NO_BOX)
menus[i].selection_color(FL_WHITE)
menus[i].textfont(FL_BOLD|FL_ITALIC)
menus[0].parent().redraw()
for i in xrange(0, 99, 1):
hugemenu.append( nm("item %d"%i) )
window = Fl_Window(0,0, WIDTH, 400)
menubar = Fl_Menu_Bar(0,0,WIDTH,30)
pulldown= ( ("Red", FL_ALT+ord('r')),
("Green", FL_ALT+ord('g')),
("Blue", FL_ALT+ord('b')),
("Strange",FL_ALT+ord('s')),
("&Charm", FL_ALT+ord('c')),
("Truth", FL_ALT+ord('t')),
("Beauty", FL_ALT+ord('b')),
(None,))
menutable = ( ("foo",0,0,0,FL_MENU_INACTIVE),
("&File",0,0,0,FL_SUBMENU),
("&Open", FL_ALT+ord('o'), 0, 0, FL_MENU_INACTIVE),
("&Close", 0, 0),
("&Quit", FL_ALT+ord('q'), quit_cb, 0, FL_MENU_DIVIDER),
("shortcut",ord('a')),
("shortcut",FL_SHIFT+ord('a')),
("shortcut",FL_CTRL+ord('a')),
("shortcut",FL_CTRL+FL_SHIFT+ord('a')),
("shortcut",FL_ALT+ord('a')),
("shortcut",FL_ALT+FL_SHIFT+ord('a')),
("shortcut",FL_ALT+FL_CTRL+ord('a')),
("shortcut",FL_ALT+FL_SHIFT+FL_CTRL+ord('a'), 0,0, FL_MENU_DIVIDER),
("shortcut",ord('\r')),
("shortcut",FL_CTRL+FL_Enter, 0,0, FL_MENU_DIVIDER),
("shortcut",FL_F+1),
("shortcut",FL_SHIFT+FL_F+1),
("shortcut",FL_CTRL+FL_F+1),
("shortcut",FL_SHIFT+FL_CTRL+FL_F+1),
("shortcut",FL_ALT+FL_F+1),
("shortcut",FL_ALT+FL_SHIFT+FL_F+1),
("shortcut",FL_ALT+FL_CTRL+FL_F+1),
("shortcut",FL_ALT+FL_SHIFT+FL_CTRL+FL_F+1, 0,0, FL_MENU_DIVIDER),
("&Submenus", FL_ALT+ord('S'), 0, "Submenu1", FL_SUBMENU),
("A very long menu item", 0),
("&submenu",FL_CTRL+ord('S'), 0, "submenu2", FL_SUBMENU),
("item 1", 0),
("item 2", 0),
("item 3", 0),
("item 4", 0),
(None, 0),
("after submenu", 0),
(None, 0),
(None, 0),
("&Edit",0,0,0,FL_SUBMENU),
("Undo", FL_ALT+ord('z'), 0),
("Redo", FL_ALT+ord('r'), 0, 0, FL_MENU_DIVIDER),
("Cut", FL_ALT+ord('x'), 0),
("Copy", FL_ALT+ord('c'), 0),
("Paste", FL_ALT+ord('v'), 0),
("Inactive",FL_ALT+ord('d'), 0, 0, FL_MENU_INACTIVE),
("Clear", 0, 0, 0, FL_MENU_DIVIDER),
("Invisible",FL_ALT+ord('e'), 0, 0, FL_MENU_INVISIBLE),
("Preferences",0, 0),
("Size", 0, 0),
(None, 0),
("&Checkbox",0,0,0,FL_SUBMENU),
("&Alpha", FL_F+2, 0, 1, FL_MENU_TOGGLE),
("&Beta", 0, 0, 2, FL_MENU_TOGGLE),
("&Gamma", 0, 0, 3, FL_MENU_TOGGLE),
("&Delta", 0, 0, 4, FL_MENU_TOGGLE|FL_MENU_VALUE),
("&Epsilon",0, 0, 5, FL_MENU_TOGGLE),
("&Pi", 0, 0, 6, FL_MENU_TOGGLE),
("&Mu", 0, 0, 7, FL_MENU_TOGGLE|FL_MENU_DIVIDER),
("Red", 0, 0, 1, FL_MENU_TOGGLE, 0, 0, 0, 1),
("Black", 0, 0, 1, FL_MENU_TOGGLE|FL_MENU_DIVIDER),
("00", 0, 0, 1, FL_MENU_TOGGLE),
("000", 0, 0, 1, FL_MENU_TOGGLE),
(None, 0),
("&Radio",0,0,0,FL_SUBMENU),
("&Alpha", 0, 0, 1, FL_MENU_RADIO),
("&Beta", 0, 0, 2, FL_MENU_RADIO),
("&Gamma", 0, 0, 3, FL_MENU_RADIO),
("&Delta", 0, 0, 4, FL_MENU_RADIO|FL_MENU_VALUE),
("&Epsilon",0, 0, 5, FL_MENU_RADIO),
("&Pi", 0, 0, 6, FL_MENU_RADIO),
("&Mu", 0, 0, 7, FL_MENU_RADIO|FL_MENU_DIVIDER),
("Red", 0, 0, 1, FL_MENU_RADIO),
("Black", 0, 0, 1, FL_MENU_RADIO|FL_MENU_DIVIDER),
("00", 0, 0, 1, FL_MENU_RADIO),
("000", 0, 0, 1, FL_MENU_RADIO),
(None, 0),
("&Font",0,0,0,FL_SUBMENU),
("Normal", 0, 0, 0, 0, 0, 0, 14),
("Bold", 0, 0, 0, 0, 0, FL_BOLD, 14),
("Italic", 0, 0, 0, 0, 0, FL_ITALIC, 14),
("BoldItalic",0,0,0, 0, 0, FL_BOLD+FL_ITALIC, 14),
("Small", 0, 0, 0, 0, 0, FL_BOLD+FL_ITALIC, 10),
("Emboss", 0, 0, 0, 0, FL_EMBOSSED_LABEL),
("Engrave", 0, 0, 0, 0, FL_ENGRAVED_LABEL),
("Shadow", 0, 0, 0, 0, FL_SHADOW_LABEL),
("@->", 0, 0, 0, 0, FL_SYMBOL_LABEL),
(None, 0),
("E&mpty",0,0,0,FL_SUBMENU),
(None, 0),
("&Inactive", 0, 0, 0, FL_MENU_INACTIVE|FL_SUBMENU),
("A very long menu item", 0),
("A very long menu item", 0),
(None, 0),
("Invisible",0, 0, 0, FL_MENU_INVISIBLE|FL_SUBMENU),
("A very long menu item", 0),
("A very long menu item", 0),
(None, 0),
# ("&Huge", 0, 0, hugemenu, FL_SUBMENU_POINTER),
("button",0, 0, 0, FL_MENU_TOGGLE),
(None,) )
menubar.copy(menutable)
menubar.callback(test_cb)
menus[0] = menubar
mb1 = Fl_Menu_Button (50,100,120,25,"&menubutton")
mb1.text = "&menubutton"
mb1.copy(pulldown)
mb1.callback(test_cb)
menus[1] = mb1
ch = Fl_Choice (250,100,80,25,"&choice:")
ch.copy(pulldown)
ch.callback(test_cb)
menus[2] = ch
ic = Fl_Input_Choice(400,100,80,25,"input")
ic.add("item1")
ic.add("item2")
ic.add("item3")
mb = Fl_Menu_Button (0,0,WIDTH,400,"&popup")
mb.type(Fl_Menu_Button.POPUP3)
mb.copy(menutable)
mb.callback(test_cb)
menus[3] = mb
sp = Fl_Spinner(100, 200, 80, 25, "spinner")
sp.format("%.1f")
sp.maximum(113)
sp.minimum(101)
sp.step(0.5)
sp.value(101.5)
print "Min/Max = ", sp.minimum(), sp.maximum()
b = Fl_Box(200,200,200,100,"Press right button\nfor a pop-up menu")
t = Fl_Toggle_Button(250,50,150,25,"MicroSoft Style")
t.callback(button_cb)
window.resizable(mb)
window.size_range(300,400,0,400)
window.end()
window.show(len(sys.argv), sys.argv)
Fl.run()
|