Description
There are a number of FLTK classes that can be derived from in Python and that allow cross-language polymorphism. Cross-language polymorphisms allow to override a method in Python and have it called from underlying C++ code. This is for instance required to give an implementation for the pure virtual method Fl_Widget::draw. On deriving from a FLTK class do not forget to call the base class constructor, as shown in the example below.
Classes
void Fl_Box::draw(void)
It is possible to provide a custom made draw method for Fl_Box.
int Fl_Box::handle(int event)
Optional implementation of an event handler. Must return 0 if the event was not handled, 1 otherwise.
|
|
void Fl_Double_Window::draw(void)
It is possible to provide a custom made draw method for Fl_Double_Window.
int Fl_Double_Window::handle(int event)
Optional implementation of an event handler. Must return 0 if the event was not handled, 1 otherwise.
|
|
void Fl_Gl_Window::draw(void)
It is possible to provide a custom made draw method for Fl_Gl_Window.
int Fl_Gl_Window::handle(int event)
Optional implementation of an event handler. Must return 0 if the event was not handled, 1 otherwise.
|
|
void Fl_Overlay_Window::draw_overlay(void)
It is possible to provide a custom made draw_overlay method for Fl_Overlay_Window. Overlays can be used for implementing visual feedback for rubber boxes etc.
|
|
void Fl_Single_Window::draw(void)
It is possible to provide a custom made draw method for Fl_Single_Window.
int Fl_Single_Window::handle(int event)
Optional implementation of an event handler. Must return 0 if the event was not handled, 1 otherwise.
|
|
Fl_Table::draw_cell(TableContext,int X, int Y, int W, int H, str label)
Fl_Table always needs an implementation of the method draw_cell.
|
|
Fl_Table_Row::draw_cell(TableContext,int X, int Y, int W, int H, str label)
Fl_Table_Row always needs an implementation of the method draw_cell.
|
|
void Fl_Widget::draw(void)
Fl_Widget always needs an implementation of the method draw.
int Fl_Widget::handle(int event)
Optional implementation of an event handler. Must return 0 if the event was not handled, 1 otherwise.
|
|
from fltk import *
class Drawing(Fl_Widget):
def __init__(self, X, Y, W, H, L):
# always intialize the base class!
Fl_Widget.__init__(self, X, Y, W, H, L)
# override method draw
def draw(self):
# simply paints the canvas red
fl_color(FL_RED)
self.redraw()
# implement event handler
def handle(event):
if event == FL_PUSH:
print "FL_PUSH caught!"
return 1
else:
return 0
window = Fl_Window(300,500)
d = Drawing(10,10,280,280, "test")
.
.
window.end()
window.show(len(sys.argv),sys.argv)
Fl.run()