The FXPy API follows the standard FOX API very closely and for the
most part you can use FOX documentation as a reference. But of course,
Python isn't C++ and so here are some differences of which you should be
aware.
FXint x, y; FXuint buttons;
if(window->getCursorPosition(x,y,buttons)) fprintf(stderr,"Current position is (%d,%d)\n",x,y);Obviously these functions must work a little differently in Python. The following table documents how such functions are implemented in FXPy:
Class Method | Return Value |
FXWindow.getCursorPosition() | Returns a tuple of integers (x, y, buttons) |
FXWindow.translateCoordinatesFrom(window, x, y) | Returns the translated coordinates as a tuple (x, y) |
FXWindow.translateCoordinatesTo(window, x, y) | Returns the translated coordinates as a tuple (x, y) |
FXGLViewer.getViewport() | Returns an FXViewport instance |
FXGLViewer.eyeToScreen(eye) | Returns the screen point coordinate as a tuple (sx, sy) |
FXGLViewer.getBoreVector(sx, sy) | Returns the endpoint and direction vector as a tuple of vectors (point, dir) |
FXGLViewer.getLight() | Returns a FXLight instance |
FXGLObject.bounds(range) | Takes an FXRange instance as its input and returns a (possibly different) FXRange instance. |
FXFontSelector.getFontSelection() | Returns the FXFontDesc instance |
FXFontDialog.getFontSelection() | Returns the FXFontDesc instance |
FXPrinterDialog.getPrinter() | Returns the FXPrinter instance |
FXScrollArea.getPosition() | Returns the position as a tuple (x, y) |
FXSpinner.getMinMax() | Returns the minimum and maximum values as a tuple |
FXSlider.getRange() | Returns the low and high values as a tuple |
FXText.extractText(pos, n) | Extracts n characters from the buffer beginning at position pos and returns the result as a string. |
As in C++ FOX, the last argument passed to your message handler functions
contains message-specific data. For instance, all SEL_PAINT messages pass
an FXEvent object through this argument to give you some information about
the size of the exposed rectangle. On the other hand, a SEL_COMMAND message
from an FXHeader object passes the index of the selected header item through
this argument. Instead of guessing what's in this last argument, your best
bet is to instead invoke a member function on the sending object to find
out what you need, instead of relying on the data passed through this pointer.
For example, if you get a SEL_COMMAND message from an FXColorWell
object, the data passed through that last argument is supposed to be the
new RGB color value. Instead of trying to interpret the argument's contents,
just turn around and call the color well's
getRGBA() member function
to retrieve its color. Similarly, if you get a SEL_COMMAND message
from a tree list, call its getCurrentItem() member function to
find out which item was selected.