On Thu, 15 Mar 2001, Joseph VanAndel wrote:
> I want to write a Python/Gtk/Glade application that uses a
> C/C++ extension to render images of weather radar data.
>
> Given that I'm rasterizing large amounts of polar coordinate
> data, I'm quite certain that I need to do the calculations
> in C/C++, rather than in Python.)
>
> 1) Which type of widget is best to use to contain these
> rendered images?
>
> Should I use a GtkPlotCanvas?
>
> 2) What's the simplest way to pass a pointer to the Gtk
> window to my C/C++ extension?
>
> It looks like I can pass "self._o" to my extension, and
> then my extension would have the form:
>
> static PyObject *_wrap_MyDraw(PyObject *self, PyObject
> *args) {
>
> PyObject *canvas;
> if (!PyArg_ParseTuple(args, "O!:MyDraw", &PyGtk_Type,
> &canvas))
> return NULL;
>
> MyDraw(GTK_PLOT_CANVAS(PyGtk_Get(canvas)));
> Py_INCREF(Py_None);
> return Py_None;
> }
>
> Is there any simpler way of doing this?
Well, if you just need to render an image to the screen, it may be easiest
to use the draw_array() function in pygtk, which draws a NumPy array
(MxNx3) to a window. This way, your extension would only need to know how
to render your polar coordinate data into the array. This is probably
easiest if you don't know much about the GTK+ programming in C.
Then you can use a drawing area with an expose_event signal handler that
simply calls draw_array.
James.
--
Email: [EMAIL PROTECTED]
WWW: http://www.daa.com.au/~james/
_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk