/usr/share/pyshared/fltk/test/subwindow.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 | # "$Id: subwindow.py 105 2005-06-24 14:38:43Z andreasheld $"
#
# Subwindows test program for pyFLTK the Python bindings
# for the Fast Light Tool Kit (FLTK).
# Test to make sure nested windows work.
# Events should be reported for enter/exit and all mouse operations
# Buttons and pop-up menu should work, indicating that mouse positions
# are being correctly translated.
#
# 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, math
class EnterExit(Fl_Box):
def __init__(self, x, y, w, h, l):
Fl_Box.__init__(self,FL_BORDER_BOX,x,y,w,h,l)
print self
# def draw(self):
# #Fl_Box.draw(self)
# pass
def handle(self, e):
print "event = ", e
if e == FL_ENTER:
try:
print "FL_ENTER"
self.color(FL_RED)
self.redraw()
except:
print 'uncaught!', sys.exc_type, sys.exc_value
return 1
elif e == FL_LEAVE:
try:
print "FL_LEAVE"
self.color(FL_GRAY)
self.redraw()
except:
print 'uncaught!', sys.exc_type, sys.exc_value
return 1
else:
return 0
class testwindow(Fl_Window):
cx = 0
cy = 0
key = '0'
def __init__(self, b, x, y, w, h, l):
Fl_Window.__init__(self,x,y,w, h,l)
self.box(b)
key = 0
def draw(self):
print self.label(), " :draw"
Fl_Window.draw(self)
if self.key:
fl_draw(self.key, 1, self.cx, self.cy)
def handle(self, e):
if e != FL_MOVE:
#print self.label(), " : ", self.eventnames[e]
print self.label()
if Fl_Window.handle(self, e):
return 1;
if e == FL_FOCUS:
return 1
if e == FL_PUSH:
Fl.focus(self.this)
return 1
if e == FL_KEYDOWN and Fl.event_text()[0]:
self.key = Fl.event_text()[0]
self.cx = Fl.event_x()
self.y = Fl.event_y()
self.redraw()
return 1
return 0
popup = None
bigmess = "this|is|only|a test"
window = testwindow(FL_UP_BOX,0,0,400,400,"outer")
tn1 = Fl_Toggle_Button(310,310,80,80,"&outer")
ee1 = EnterExit(10,310,80,80,"enterexit")
fi1 = Fl_Input(150,310,150,25,"input:")
mb1 = Fl_Menu_Button(5,150,80,25,"menu&1")
#setMenu(mb1, ( ("this",), ("is",), ("only",), ("a test",), (None,)))
mb1.menu(( ("this",), ("is",), ("only",), ("a test",), (None,)))
#mb1.add(bigmess)
subwindow = testwindow(FL_DOWN_BOX,100,100,200,200,"inner")
#subwindow = Fl_Window(FL_DOWN_BOX,100,100,200,200,"inner")
tn2 = Fl_Toggle_Button(310,310,80,80,"&outer")
subwindow.add(tn2)
ee2 = EnterExit(10,310,80,80,"enterexit")
subwindow.add(ee2)
fi2 = Fl_Input(150,310,150,25,"input:")
subwindow.add(fi2)
mb2 = Fl_Menu_Button(5,150,80,25,"menu&2")
#mb2.add(bigmess)
#setMenu(mb2, ( ("this",), ("is",), ("only",), ("a test",), (None,)))
mb2.menu(( ("this",), ("is",), ("only",), ("a test",), (None,)))
subwindow.end()
subwindow.resizable(subwindow)
window.resizable(subwindow)
window.add(subwindow)
fb = Fl_Box(FL_NO_BOX,0,0,400,100,
"A child Fl_Window with children of it's own may "
"be useful for imbedding controls into a GL or display "
"that needs a different visual. There are bugs with the "
"origins being different between drawing and events, "
"which I hope I have solved."
)
fb.align(FL_ALIGN_WRAP)
popup = Fl_Menu_Button(0,0,400,400)
popup.type(Fl_Menu_Button.POPUP3)
#setMenu(popup, ( ("This",), ("is",), ("a popup",), ("menu",), ("this",), ("is",), ("only",), ("a test",), (None,)))
popup.menu(( ("This",), ("is",), ("a popup",), ("menu",), ("this",), ("is",), ("only",), ("a test",), (None,)))
#popup.add("This|is|a popup|menu")
#popup.add(bigmess)
window.add(fb)
window.add(popup)
window.end()
#window.show(len(sys.argv), sys.argv)
window.show()
print "rec = ", sys.getrecursionlimit()
#sys.setrecursionlimit(2000)
#print "rec = ", sys.getrecursionlimit()
Fl.run()
|