accessing BLT vectors from C

genehilton at my-deja.com genehilton at my-deja.com
Fri Apr 21 21:11:47 CEST 2000


Has anyone out there written anything that will enable me to access
the BLT C api.  I am using BLT as a part of a data acquisition
system.  It works great, but filling the vectors is really slow in
python.  I wrote a python module in C to use the Blt c api, but it can't
find the vectors I created with Pmw.Blt.Vector().  I can access (in the
c module) vectors that I create in the c-module.  This must be some sort
of TCL thing I don't understand.  Here is a snippet from the C module


        if (!PyArg_ParseTuple(args, "OO",&master,&bltobj)) return NULL;

/* get the name of the vector - PMW stores it as the repr. */
        bltobjname=PyObject_Str(bltobj);
        if (!bltobjname) return NULL;
        bltname=PyString_AsString(bltobjname);
        if (!bltname) return NULL;
        printf("%s\n",bltname);
/* get the interpreter from an argument (for now) */
         interp=((TkappObject *)master)->interp;

/* this doesn't work (returns a 0) */
	printf("%d\n",Blt_VectorExists(interp,bltname));
        printf("%d\n",Blt_CreateVector(interp,"myvec",1,&vec));
/* this works (returns a 1) */
        printf("%d\n",Blt_VectorExists(interp,"myvec"));

I call it with the following python code

import Tkinter
import Pmw
import mymod
v=Pmw.Blt.Vector(1)
mymod.myroutine(master.tk,v)
v=Pmw.Blt.Vector(1)

I get an output like
0     (couldn't find it - v created in python)
0     (created ok in c)
1     (found the one created in c)

Any pointers would be real helpful

Gene Hilton
hilton at boulder.nist.gov


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list