Debian Codegraph @

fltk/test/chart.py

raw symbols SCIP
1 #
2 # "$Id: chart.py 28 2003-07-16 20:00:27Z andreasheld $"
3 #
4 # Charts 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
30 # Note: the child windows are assigned to the charts list
31 # for the program to exit correctly, the Python shadows
32 # must be deleted. this is accomplished by the charts=None
33 # in the exit function
34 charts =[]
35
36 def cb_OK(ptr):
37 global charts
38 charts = None ### <- this allows the program to exit
39 sys.exit(0)
40
41
42 graphWidth = 150
43 graphHeight = 100
44 border = 30
45 numRows = 3
46 numCols = 3
47 buttonWidth = 60
48 buttonHeight = 30
49
50
51 # ugly, hacked coordinates
52 x1 = border
53 x2 = (border*2)+graphWidth
54 x3 = (border+graphWidth)*2+border
55 y1 = border
56 y2 = border*2+graphHeight
57 y3 = border*3+graphHeight*2
58 chartInfo = [ \
59 (FL_BAR_CHART,"FL_BAR_CHART", x1, y1),
60 (FL_HORBAR_CHART,"FL_HORBAR_CHART", x2, y1),
61 (FL_LINE_CHART,"FL_LINE_CHART", x3, y1),
62 (FL_SPIKE_CHART,"FL_SPIKE_CHART", x1, y2),
63 (FL_PIE_CHART,"FL_PIE_CHART", x2, y2),
64 (FL_SPECIALPIE_CHART,"FL_SPECIALPIE_CHART", x3, y2),
65 (FL_FILL_CHART,"FL_FILL_CHART", x1, y3) ]
66
67
68 foo_window = Fl_Window(100, 100, border+numCols*(border+graphWidth),
69 numRows*(border+graphHeight)+border+buttonHeight+border)
70
71 for chartParams in chartInfo:
72 chart = Fl_Chart(chartParams[2], chartParams[3],
73 graphWidth, graphHeight, chartParams[1])
74 chart.type(chartParams[0])
75 chart.add(2, "Win 3.1", 0)
76 chart.add(3, "Dos", 1)
77 chart.add(5, "NT", 3)
78 chart.add(10, "Linux", 2)
79 charts.append(chart)
80
81 okButton = Fl_Return_Button( (numCols-1)*(graphWidth+border),
82 numRows*(graphHeight+border)+border, buttonWidth, buttonHeight, "OK")
83 okButton.callback(cb_OK)
84
85 foo_window.end()
86 foo_window.show(len(sys.argv), sys.argv)
87
88 Fl.run()
89