Debian Codegraph @

fltk/test/GlobalHandler.py

raw symbols SCIP
1 #
2 # "$Id: GlobalHandler.py 493 2012-02-14 21:40:41Z andreasheld $"
3 #
4 # Global handler 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
29
30 def EventHandler1(event):
31 print("EventHandler1: ", event)
32 if event == FL_SHORTCUT:
33 print("Received FL_SHORTCUT", Fl.event_key())
34 return 1
35 else:
36 return 0
37
38 def EventHandler2(event):
39 print("EventHandler2: ", event)
40 if event == FL_SHORTCUT:
41 print("Received FL_SHORTCUT", Fl.event_key())
42 return 1
43 else:
44 return 0
45
46 def CheckHandler1(data):
47 print("CheckHandler1: ", data)
48
49 def CheckHandler2():
50 print("CheckHandler2: no data")
51
52
53 cb1 = 0
54 cb2 = 0
55 cb3 = 0
56 cb4 = 0
57
58 def Handler1CB(widget):
59 global cb1
60 if cb1:
61 widget.label("Add Handler1")
62 Fl.remove_handler(EventHandler1)
63 cb1 = 0
64 else:
65 widget.label("Remove Handler1")
66 Fl.add_handler(EventHandler1)
67 cb1 = 1
68
69 def Handler2CB(widget):
70 global cb2
71 if cb2:
72 widget.label("Add Handler2")
73 Fl.remove_handler(EventHandler2)
74 cb2 = 0
75 else:
76 widget.label("Remove Handler2")
77 Fl.add_handler(EventHandler2)
78 cb2 = 1
79
80 def Check1CB(widget):
81 global cb3
82 if cb3:
83 widget.label("Add Check1")
84 Fl.remove_check(CheckHandler1)
85 cb3 = 0
86 else:
87 widget.label("Remove Check1")
88 Fl.add_check(CheckHandler1, "Check1")
89 cb3 = 1
90
91 def Check2CB(widget):
92 global cb4
93 if cb4:
94 widget.label("Add Check2")
95 Fl.remove_check(CheckHandler2)
96 cb4 = 0
97 else:
98 widget.label("Remove Check2")
99 Fl.add_check(CheckHandler2)
100 cb4 = 1
101
102 win = Fl_Window(100,150,300,200, "GloablHandler")
103 b1 = Fl_Button(20,50,120,30,"Add Handler1")
104 b1.callback(Handler1CB)
105 b2 = Fl_Button(160,50,120,30,"Add Handler2")
106 b2.callback(Handler2CB)
107
108 b3 = Fl_Button(20,100,120,30,"Add Check1")
109 b3.callback(Check1CB)
110 b4 = Fl_Button(160,100,120,30,"Add Check2")
111 b4.callback(Check2CB)
112
113 win.show()
114
115 Fl.run()
116
117
118
119