Debian Codegraph @

fltk/test/browser.py

raw symbols SCIP
1 """
2 //
3 // "$Id: browser.py 536 2020-10-30 15:20:32Z andreasheld $"
4 //
5 // Browser test program for pyFLTK the Python bindings
6 // for the Fast Light Tool Kit (FLTK).
7 //
8 // Copyright 1998-1999 by Bill Spitzak and others.
9 // pyFLTK copyright 2003 by Andreas Held and others.
10 //
11 // This library is free software you can redistribute it and/or
12 // modify it under the terms of the GNU Library General Public
13 // License, version 2.0 as published by the Free Software Foundation.
14 //
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Library General Public License for more details.
19 //
20 // You should have received a copy of the GNU Library General Public
21 // License along with this library if not, write to the Free Software
22 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 // USA.
24 //
25 # Please report all bugs and problems to "[email protected]".
26 #
27
28 /*
29 This is a test of how the browser draws lines.
30 This is a second line.
31 This is a third.
32
33 That was a blank line above this.
34
35 @r@_Right justify
36 @c@_Center justify
37 @_Left justify
38
39 @bBold text
40 @iItalic text
41 @b@iBold Italic
42 @fFixed width
43 @f@bBold Fixed
44 @f@iItalic Fixed
45 @f@i@bBold Italic Fixed
46 @lLarge
47 @l@bLarge bold
48 @sSmall
49 @s@bSmall bold
50 @s@iSmall italic
51 @s@i@bSmall italic bold
52 @uunderscore
53 @C1RED
54 @C2Green
55 @C4Blue
56
57 You should try different browser types:
58 Fl_Browser
59 Fl_Select_Browser
60 Fl_Hold_Browser
61 Fl_Multi_Browser
62 */
63 """
64
65 from fltk import *
66 import sys
67
68 def b_cb(ptr):
69 #print "callback, selection = %d, event_clicks = <not yet wrapped>"%(ptr.value())
70 print(f"callback, selection = {ptr.value()}, event_clicks = {Fl.event_clicks()}")
71
72 def show_cb(ptr):
73 if field.value() == '':
74 fl_alert("Please enter a number in the text field\n"
75 "before clicking on the buttons.")
76 return
77 line = int(field.value())
78 if str(ptr) == str(top):
79 browser.topline(line)
80 elif str(ptr) == str(bottom):
81 browser.bottomline(line)
82 elif str(ptr) == str(middle):
83 browser.middleline(line)
84 else:
85 browser.make_visible(line)
86
87 # if (!Fl::args(argc,argv,i)) Fl::fatal(Fl::help)
88
89 fname = "browser.py"
90 window = Fl_Window(400,400,fname)
91 #window.box(FL_NO_BOX) # because it is filled with browser
92
93 browser = Fl_Select_Browser(0,0,400,350,"")
94
95 browser.type(FL_MULTI_BROWSER)
96 #browser.color(44)
97 browser.callback(b_cb)
98 print("Browser font = ", browser.textfont())
99 print("Setting browser font to Courier")
100 browser.textfont(FL_COURIER)
101 print("Browser font size = ", browser.textsize())
102 print("Setting browser font size to 11")
103 browser.textsize(11)
104 print("Browser font color = ", browser.textcolor())
105 print("Setting browser font color to red")
106 browser.textcolor(FL_RED)
107
108 browser.scrollbar_right()
109 browser.has_scrollbar(Fl_Browser.BOTH_ALWAYS)
110
111 if not browser.load(fname):
112 print("Can't load " + fname)
113 sys.exit(1)
114
115 browser.vposition(0)
116
117 field = Fl_Int_Input(50,350,350,25,"Line #:")
118 field.callback(show_cb)
119
120 top = Fl_Button(0,375,100,25,"Top")
121 top.callback(show_cb)
122
123 bottom = Fl_Button(100, 375, 100, 25, "Bottom")
124 bottom.callback(show_cb);
125
126 middle = Fl_Button(200, 375, 100, 25, "Middle")
127 middle.callback(show_cb);
128
129 visible = Fl_Button(300, 375, 100, 25, "Make Vis.")
130 visible.callback(show_cb);
131
132 window.end()
133
134 window.resizable(browser)
135 window.show(len(sys.argv), sys.argv)
136 Fl.run()
137
138