accessing BLT vectors from C

Greg McFarlane gregm at iname.com
Thu Apr 27 08:08:21 EDT 2000


Gene,

What is the value of bltname?  The names that Pmw give to Blt vectors
are PY_VEC0, PY_VEC1, PY_VEC2, etc.  You can see what Tcl calls are
being made by calling Pmw.tracetk().  For example, this Pmw:
    v = Pmw.Blt.Vector(1)
prints:
    CALL  TK> 1:  ('::blt::vector', 'create', 'PY_VEC0(1)') -> '::PY_VEC0'
Which means, in tcl:
    ::blt::vector create PY_VEC0(1)
	--> ::PY_VEC0

So Blt_VectorExists(interp,"PY_VEC0") should return true.  If not, I'm
not sure what the problem is.

Greg

On 21 Apr, genehilton at my-deja.com wrote:
> 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.
> -- 
> http://www.python.org/mailman/listinfo/python-list
> 

-- 
Greg McFarlane     INMS Telstra Australia     gregm at iname.com




More information about the Python-list mailing list