# -*- coding: utf-8 -*- import sys sys.path.append('..') import svgplotlib.FLTK as Fl window = Fl.Window(400, 420) output = Fl.Output(100, 20, 200, 30, "Fl_Output") output.value('single text line') moutput = Fl.Multiline_Output(100, 60, 200, 70, "Fl_Multiline_Output") moutput.value('first text line\nsecond text line') window.end() window.show() Fl.run()
<rect x="100" y="100" width="400" height="200" rx="50" fill="green" /> <g transform="translate(700 210) rotate(-30)"> <rect x="0" y="0" width="400" height="200" rx="50" fill="none" stroke="purple" stroke-width="30" /> </g> </svg> """) renderer = Renderer(xmltree) import svgplotlib.FLTK as Fl WIDTH, HEIGHT = 600, 700 window = Fl.Window(WIDTH, HEIGHT) width, height = renderer.width, renderer.height widget = Fl.Button(10, 10, width, height) pixels = vg.PixelBuffer(width, height) ctx = vg.CreateOffScreenSH() vg.StartOffScreenSH(ctx, width, height) vg.Setfv(vg.CLEAR_COLOR, 4, [1., 1., 1., 1.]) vg.Clear(0, 0, width, height) # center on bounding box box = renderer.bounds scale = min(width / box.width, height / box.height)
# -*- coding: utf-8 -*- import sys sys.path.append('..') import svgplotlib.FLTK as Fl def filecb(widget, data): native = Fl.Native_File_Chooser() native.set_title("Pick a file") native.set_filter('''Text\t*.txt C Files\t*.{cxx,h,c} Apps\t*.{app}\n''') ret = native.show() if ret == -1: print 'Error ', native.errmsg() elif ret == 1: print 'Cancel' else: print native.filename() def exitcb(widget, data): Fl.exit() window = Fl.Window(320,65) b1 = Fl.Button(20, 20, 80, 25, "&Select file") b1.callback(filecb) b3 = Fl.Button(220,20, 80, 25, "E&xit") b3.callback(exitcb) window.end() window.show() Fl.run()
# -*- coding: utf-8 -*- import sys sys.path.append('..') import svgplotlib.FLTK as Fl def cb(widget, data): print 'called' print widget, data WIDTH = 700 window = Fl.Window(WIDTH, 400) menubar = Fl.Menu_Bar(0, 0, WIDTH, 30) menubar.add("&File", 0, None, None, Fl.SUBMENU) menubar.add("File/Exit1", 0, cb, 'test1') menubar.add("File/Exit2", 0, cb, 'test2') button = Fl.Menu_Button(10, 50, WIDTH / 2, 30, 'Menu Button') button.add("Exit1", 0, cb, 'test1') button.add("Exit2", 0, cb, 'test2') choice = Fl.Choice(WIDTH / 4, 100, WIDTH / 2, 30, 'Choice Button') first = choice.add("Exit1", 0, cb, 'test1') choice.add("Exit2", 0, cb, 'test2') choice.value(first) window.end() window.show()
# -*- coding: utf-8 -*- import sys sys.path.append('..') import svgplotlib.FLTK as Fl def beepcb(widget, data): print 'beep' def exitcb(widget, data): Fl.exit() window = Fl.Window(320, 65, 'Buttons') b1 = Fl.Button(20, 20, 80, 25, "&Beep") b1.callback(beepcb) b3 = Fl.Button(220, 20, 80, 25, "E&xit") b3.callback(exitcb) window.end() window.show() Fl.run()
# -*- coding: utf-8 -*- import sys sys.path.append('..') import svgplotlib.FLTK as Fl window = Fl.Window(320, 320) b1 = Fl.Button(10, 10, 300, 300) image1 = Fl.PNG_Image('sudoku-128.png') b1.image(image1) window.end() window.show() Fl.run()