Extending python - undefined symbol error on import

2005-07-22 Thread ch424
Hi there,

I'm using Python 2.4.1 on Ubuntu Linux, and I'm having problems
extending python in C:

The C code is below:

#include 
#include "ni488.h"

static PyObject *
gpib_hello(PyObject *self, PyObject *args)
{
char *command;
int *secondarg;
 //   int sts;

if (!PyArg_ParseTuple(args, "|si", &command, &secondarg)) //both
arguments are optional
return NULL;

// TODO: Inserting code for the function here!

// FROM HERE
int Device = 0;   /* Device unit descriptor*/
int BoardIndex = 0;   /* Interface Index*/

int   PrimaryAddress = 13;  /* Pri addr of the device */
int   SecondaryAddress = 0;/* Sec addr of the device */

Device = ibdev(/* Create a unit descriptor handle */
BoardIndex,  /* Board Index*/
PrimaryAddress,  /* Device pri addr */
SecondaryAddress,/* Device sec addr*/
T10s,/* Timeout setting = 10 seconds */
1,   /* Assert EOI line at end of write */
0);  /* EOS termination mode */

// TO HERE IS THE GPIB STUFF

return Py_BuildValue("s", "hello world");
}


static PyMethodDef gpibMethods[] = {
/* ...  */
{"hello",  gpib_hello, METH_VARARGS,
 "Get Hello world returned."},
/* ...  */
{NULL, NULL, 0, NULL}/* Sentinel */
};

PyMODINIT_FUNC
initgpib(void)
{
(void) Py_InitModule("gpib", gpibMethods);
}

As you can see, it's the standard "spammodule" example, with "spam"
replaced with "gpib", an extra include (ni488) and that block of code
added. This compiles absolutely faultlessly (even no warnings!) using
the python script:

from distutils.core import setup, Extension

module1 = Extension('gpibmodule',
sources = ['gpibmodule.c'])

setup (name = 'gpibmodule',
version = '0.0.1',
description = 'This is the gpib package',
ext_modules = [module1])

However, when I open up the python command line, and type "from gpib
import *" or "import gpib" I get "ImportError: /usr/.../gpibmodule.so:
undefined symbol: ibdev" -- but I know it's defined in the ni488.h
file, especially as I can use this code from actual C programs without
problems. The ni488.h file in in the right place to be used for C
compilation.

So, the question is, what did I type wrong? Why is python examining
that c function embedded in another, surely it should only be
interested in providing arguments and getting returned values, and what
the c function does is its own bussiness?

Any help would be hugely appreceated!

Thanks

Alex

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Extending python - undefined symbol error on import

2005-07-25 Thread ch424
Sweet! It works! *dances*

Thank you so much -- and for the explanation! For anyone searching for
this, I had to change the respective lines to:

module1 = Extension('gpibmodule',
libraries = ['gpibapi'],
sources = ['gpibmodule.c'])

just as Daniel said.

Thanks again,

Alex

-- 
http://mail.python.org/mailman/listinfo/python-list


pygtk - scale widget events

2005-07-27 Thread ch424
Hi

I'm trying to make a zooming in/out slider, but I want to make it
re-center when I let go of the mouse button on it -- i.e. it starts
with a value of 1 (in the center of the slider), then the user can drag
it to the right or left, while it does UPDATE_CONTINUOUS, but when the
user lets go, I want it to go back to 1 (its center value) again.

So, basically, my question is: Is it possible to make a scale widget
with UPDATE_CONTINUOUS reset to a value when the user releases the
mouse button on it?

Many thanks for any help,

Alex

-- 
http://mail.python.org/mailman/listinfo/python-list


Trigger pygtk drawingarea redraw

2005-07-28 Thread ch424
Hi,

Does anybody know the fastest way to trigger a DrawingArea redaw in
pygtk? At the moment, I'm using a bit of a hack:

def redraw(self):
self.area.hide()
self.area.show()

Is there a better way to trigger a redraw? This causes flickering when
the window gets bigger than 400x400 pixels, which is a nuisance...
there must be a better way of clearing the area and letting it redraw
itself?


Many thanks for any help,

Alex

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Trigger pygtk drawingarea redraw

2005-07-28 Thread ch424
Ahh.. fantastic! Flickers be gone! Yaarrrg!

It was "self.area.queue_draw()" in case anyone wants to know. :)

Thanks so much!

Alex

-- 
http://mail.python.org/mailman/listinfo/python-list