Debian Codegraph @

fltk/test/cursor.py

raw symbols SCIP
1 #
2 # "$Id: cursor.py 35 2003-09-29 21:39:48Z andreasheld $"
3 #
4 # Cursor 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
28 from fltk import *
29 import sys
30
31
32 fg = FL_BLACK
33 bg = FL_WHITE
34 cursor = FL_CURSOR_DEFAULT
35
36 #Fl_Hor_Value_Slider *cursor_slider;
37 cursor_slider = ''
38
39 def choice_cb(ptr, value):
40 global cursor
41 global fg
42 global bg
43 cursor = value
44 cursor_slider.value(cursor)
45 fl_cursor(cursor, fg, bg)
46
47
48
49 def setcursor(slider):
50 global cursor
51 global fg
52 global bg
53 #slider = castWidget2Slider(ptr)
54 cursor = int(slider.value())
55 fl_cursor(cursor, fg, bg)
56
57 def setfg(slider):
58 global cursor
59 global fg
60 global bg
61 #slider = castWidget2Slider(ptr)
62 fg = int(slider.value())
63 fl_cursor(cursor, fg, bg)
64
65 def setbg(slider):
66 global cursor
67 global fg
68 global bg
69 #slider = castWidget2Slider(ptr)
70 bg = int(slider.value())
71 fl_cursor(cursor, fg, bg)
72
73
74 # draw the label without any ^C or \nnn conversions:
75 class CharBox(Fl_Box):
76 def __init__(self, X, Y, W, H, L):
77 #Super(X,Y,W,H,L)
78 Fl_Box.__init__(self, X,Y,W,H,L)
79 def draw():
80 fl_font(FL_FREE_FONT,14)
81 fl_draw(label(), x()+w()/2, y()+h()/2)
82
83
84
85 window = Fl_Window(400,300)
86
87 choice = Fl_Choice(80,100,200,25,"Cursor:")
88 #choice.menu(choices)
89 choice.copy(
90 (( ("FL_CURSOR_DEFAULT",0,choice_cb,FL_CURSOR_DEFAULT),
91 ("FL_CURSOR_ARROW",0,choice_cb,FL_CURSOR_ARROW),
92 ("FL_CURSOR_CROSS",0,choice_cb,FL_CURSOR_CROSS),
93 ("FL_CURSOR_WAIT",0,choice_cb,FL_CURSOR_WAIT),
94 ("FL_CURSOR_INSERT",0,choice_cb,FL_CURSOR_INSERT),
95 ("FL_CURSOR_HAND",0,choice_cb,FL_CURSOR_HAND),
96 ("FL_CURSOR_HELP",0,choice_cb,FL_CURSOR_HELP),
97 ("FL_CURSOR_MOVE",0,choice_cb,FL_CURSOR_MOVE),
98 ("FL_CURSOR_NS",0,choice_cb,FL_CURSOR_NS),
99 ("FL_CURSOR_WE",0,choice_cb,FL_CURSOR_WE),
100 ("FL_CURSOR_NWSE",0,choice_cb,FL_CURSOR_NWSE),
101 ("FL_CURSOR_NESW",0,choice_cb,FL_CURSOR_NESW),
102 ("FL_CURSOR_NONE",0,choice_cb,FL_CURSOR_NONE),
103 (None,) ) ))
104 choice.callback(choice_cb)
105 #choice.when(FL_WHEN_RELEASE|FL_WHEN_NOT_CHANGED)
106
107 slider1 = Fl_Hor_Value_Slider(80,180,310,30,"Cursor:")
108 cursor_slider = slider1
109 slider1.align(FL_ALIGN_LEFT)
110 slider1.step(1)
111 slider1.precision(0)
112 slider1.bounds(0,100)
113 slider1.value(0)
114 slider1.callback(setcursor)
115 slider1.value(cursor);
116
117 slider2 = Fl_Hor_Value_Slider(80,220,310,30,"fgcolor:")
118 slider2.align(FL_ALIGN_LEFT)
119 slider2.step(1)
120 slider2.precision(0)
121 slider2.bounds(0,255)
122 slider2.value(0)
123 slider2.callback(setfg)
124 slider2.value(fg)
125
126 slider3 = Fl_Hor_Value_Slider(80,260,310,30,"bgcolor:")
127 slider3.align(FL_ALIGN_LEFT)
128 slider3.step(1)
129 slider3.precision(0)
130 slider3.bounds(0,255)
131 slider3.value(0)
132 slider3.callback(setbg)
133 slider3.value(bg)
134
135 window.resizable(window)
136 window.end()
137 window.show(len(sys.argv),sys.argv)
138 Fl.run()