Problem EmbedingPython w/ Tkinter in C on Linux
Rick Olson
r_olson at sandiego.edu
Mon Jul 22 21:11:58 EDT 2002
Hi--
I'm using Python 2.2 on a machine running Red Hat 7.2. I have some
Python scripts that use Tkinter that I would like to use as the
elements for the interface for a large C program. Consequently, I'm
trying to embed the Python/Tkinter into C. It isn't practical for me
to try to extend the C routines from Python. To complicate things, I
an relatively green at Linux.
I was able to run the embedding demo program. I also built a 3 line
pythohn script that justs opens a Tkinter window. It runs fine using
Idle. Next I tried using RunPy_SimpleFile to run the script. I ran
into problems, so I backed . I can compile, but something is missing
as when I try to run the program I get:
Traceback (most recent call last):
File "test.py", line 1, in ?
File "/usr/lib/python2.2/lib-tk/Tkinter.py", line 35, in ?
import _tkinter # If this fails your Python may not be
configured for Tk
ImportError: /usr/lib/python2.2/lib-dynload/_tkinter.so: undefined
symbol: _Py_NoneStruct
I attempted to add tcl and tk libraries to the demo makefile and am
now using the makefile below. Can someone help identify where I'm
running into problems?
Thanks in advance--
Rick Olson
# Makefile for embedded Python modified to include tk and tcl.
CC= gcc
# Python version
VERSION= 2.2
# Top of the build tree and source tree
blddir= /usr/lib/python2.2/config
srcdir= /usr/include/python2.2
# Compiler flags
OPT= -g
INCLUDES= -I$(srcdir)/Include -I$(blddir) -I$(srcdir)
CFLAGS= $(OPT) $(INCLUDES)
# The Python library
LIBPYTHON= $(blddir)/libpython$(VERSION).a
# XXX edit LIBS (in particular) to match $(blddir)/Modules/Makefile
TKLIBS= -ltcl8.3 -ltk8.3
LIBS= -lnsl -ldl -lreadline -ltermcap -lpthread -lieee -lutil
SYSLIBS= -lm
MODLIBS=
ALLLIBS= $(TKLIBS) $(LIBPYTHON) $(MODLIBS) $(LIBS) $(SYSLIBS)
# Build the demo application
all: CallTkinter
CallTkinter: CallTkinter.o
$(CC) CallTkinter.o $(ALLLIBS) -o CallTkinter
# Administrative targets
test: CallTkinter sh make
./CallTkinter
clean:
-rm -f *.o core
clobber: clean
-rm -f *~ @* '#'* CallTkinter
More information about the Python-list
mailing list