Debian Codegraph @

fltk/test/check_browser.py

raw symbols SCIP
1 #
2 # "$Id: check_browser.py 536 2020-10-30 15:20:32Z andreasheld $"
3 #
4 # Check browser 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 # global object names
31 aCheckBrowser = None # type 'Check_Browser' from '()'
32
33
34 def checkBrowserCallback(ptr):
35 #cb = Fl_Check_BrowserPtr(ptr) # code
36 cb = ptr
37 print(f"contains {cb.nitems()} items")
38 for i in range(1, cb.nitems()+1): # code
39 if cb.checked(i): # code
40 print(cb.text(i)+" is checked")
41 else: # code
42 print(cb.text(i)+" is not checked")
43
44
45 def onOK(ptr):
46 import sys # code
47 checkBrowserCallback(aCheckBrowser) # code
48 sys.exit(0) # code
49
50
51 def main():
52 global aCheckBrowser
53
54 win = Fl_Window(394, 309, 245, 133, "check_browser.py")
55
56 aCheckBrowser = Fl_Check_Browser(5, 5, 240, 75)
57 aCheckBrowser.callback(checkBrowserCallback)
58 aCheckBrowser.end()
59
60 btn = Fl_Return_Button(160, 90, 70, 30, "OK")
61 btn.label('OK')
62 btn.callback(onOK)
63 win.label('check_browser.py')
64 win.end()
65 aCheckBrowser.add("Guiness", 1) # code
66 aCheckBrowser.add("Bud") # code
67 aCheckBrowser.add("Coors") # code
68 aCheckBrowser.add("Grimbergen", 1) # code
69 aCheckBrowser.add("Burning River", 1) # code
70 aCheckBrowser.add("Little Kings") # code
71
72 return win
73
74
75
76 if __name__=='__main__':
77 import sys
78 window = main()
79 window.show(len(sys.argv), sys.argv)
80 Fl.run()