Debian Codegraph @

fltk/test/adjuster.py

raw symbols SCIP
1 #
2 # "$Id: adjuster.py 35 2003-09-29 21:39:48Z andreasheld $"
3 #
4 # Adjuster test program for pyFLTK the Python bindings
5 # for the Fast Light Tool Kit (FLTK).
6 #
7 # FLTK copyright 1998-1999 by Bill Spitzak and others.
8 # pyFLTK copyright 2003 by Andreas Held and others.
9 #
10 # This library is free software you can redistribute it and/or
11 # modify it under the terms of the GNU Library General Public
12 # License, version 2.0 as published by the Free Software Foundation.
13 #
14 # This library is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 # Library General Public License for more details.
18 #
19 # You should have received a copy of the GNU Library General Public
20 # License along with this library if not, write to the Free Software
21 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22 # USA.
23 #
24 # Please report all bugs and problems to "[email protected]".
25 #
26
27 from fltk import *
28 import sys
29 import time
30
31 label = ""
32
33 def adjcb(ptr, widget):
34 ret = ptr.format(widget.label())
35 widget.label(ret[1])
36 widget.redraw()
37 return None
38
39 def adjcb2(ptr, widget):
40 global label # need to keep this global to avoid garbage collection
41 label = widget.label()
42 ret = ptr.format(label)
43 widget.label(label)
44 widget.redraw()
45 return None
46
47 class My_Adjuster(Fl_Adjuster):
48 def _init__(self, x, y, w, h, label):
49 Fl_Adjuster.__init__(self, x, y, w, h, label, len(label))
50
51 def format(self, buffer):
52 #print(f"Buffer = {buffer}")
53 buffer = str(2*self.value()).ljust(6, '0')
54 #print(f"Buffer = {buffer}")
55 return len(buffer), buffer
56
57 window = Fl_Window(320,100)
58 buf1 = '0.0000'
59 b1 = Fl_Box(FL_DOWN_BOX,20,30,80,25,buf1)
60 b1.color(FL_WHITE)
61 a1 = Fl_Adjuster(20+80,30,3*25,25)
62 a1.callback(adjcb2,b1)
63
64 buf2 = '0.0000'
65 b2 = Fl_Box(FL_DOWN_BOX,20+80+4*25,30,80,25,buf2)
66 b2.color(FL_WHITE)
67 a2 = My_Adjuster(b2.x()+b2.w(),10,25,3*25)
68 a2.callback(adjcb,b2)
69
70 window.resizable(window)
71 window.end()
72 window.show()
73
74 Fl.run()