Debian Codegraph @

fltk/test/demos.py

raw symbols SCIP
1 #
2 # "$Id: demos.py 531 2019-12-27 12:15:45Z andreasheld $"
3 #
4 # 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
30 # global object names
31 demoList = [] # type 'Fl_Browser' from '()'
32
33
34 import os, glob, sys
35
36 def onOK(ptr):
37 import sys
38 sys.exit(0)
39
40
41 def runDemo(ptr):
42 if sys.platform == 'win32':
43 os.system("python "+demoList.text(demoList.value()))
44 else:
45 os.system("python3 "+demoList.text(demoList.value()))
46
47 def fillList():
48 files = glob.glob("*.py")
49 files.sort()
50 for file in files:
51 if not file in ['fltk.py', 'fltk_pre.py', 'demos.py', 'browserData.py']:
52 demoList.add(file)
53
54
55 def main():
56 global demoList
57
58 win = Fl_Window(451, 190, 192, 231)
59
60 demoList = Fl_Select_Browser(5, 5, 180, 150, "Click to run a demo")
61 demoList.label('Click to run a demo')
62 demoList.callback(runDemo)
63 fillList() # extra code
64 demoList.end()
65
66 btn = Fl_Return_Button(115, 185, 50, 25, "OK")
67 btn.label('OK')
68 btn.callback(onOK)
69 win.end()
70
71 return win
72
73
74
75 if __name__=='__main__':
76 import sys
77 window = main()
78 window.show(sys.argv)
79 Fl.run()