building _tkinter module with .NET 2005?

2007-04-27 Thread joshusdog
I have the Python 2.5.1 source and I'm trying to build the debug
version of the _tkinter module. I've got .NET 2005 (Visual Studio 8)
but the instructions in the pcbuild\readme.txt file only contain
instructions for using .NET 2003 (Visual Studio 7.1). There's another
readme.txt file under the pcbuild8 directory, but is almost identical
to the one in the pcbuild folder. (There's some information about some
new instrumented build settings, but that's about it)

The instructions contained in both these readme.txt files say that the
Tcl, Tk, and Tix projects must be built from the command line first,
using nmake.exe in conjunction with the corresponding makefile.vc for
each package. I can get this to work using .NET 2003, but not
with .NET 2005. Is there an updated set of instructions somewhere for
doing this with .NET 2005? Is it even possible to get it to work with
the newer version of .NET?

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


integrating embedded interpreter with external controls

2007-05-07 Thread joshusdog
I need some advice about how to go about architecting a solution to
the following problem.

I'd like to create an application that has an interactive listener/
console window in which the user can enter commands (in much the same
vain as 3D Studio Max, for those who are familiar with the product).
The console would essentially be an embedded Python interpreter
running the interactive loop (a call to the C API's
PyRun_InteractiveLoop()).

I'd also like buttons and other UI controls to be able to access
functions and objects that are defined through the console. I'm not
really sure how to integrate the UI controls with the console though,
especially if the console is running PyRun_InteractiveLoop(), which is
a tight loop.

I'm guessing that the solution will most likely require the console to
run in a separate thread, but I still don't know how to get the UI to
interact with the console.

Does anyone have any helpful suggestions?

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


multi-line input?

2007-05-14 Thread joshusdog
I'm writing a C++ application with an embedded Python interpreter.
Command text is captured and passed to the interpreter a single line
at a time. My question is this: is there a simple way of determining
whether a given input line of text will cause the prompt to change
from the regular ">>>" to the multi-line "..." before sending the text
to the interpreter? I suppose the completely correct solution would be
tokenize and parse the entire string and then examine all the
constituent parts, but that seems like a lot more work than I really
want to do.

As far as I can tell, there are only a few ways to trigger the multi-
line input prompt:

- if-statement, for-loop, function or class definition
- line continuation (\)
- block quote (""" or ''')

Any help would be greatly appreciated.

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


Re: multi-line input?

2007-05-15 Thread joshusdog
Ah, thanks. Using the information you provided, I found the following
page:

http://archives.free.net.ph/message/2303.091004.4da616bf.en.html

It's not perfect, but it's close enough for what I need.

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


newbie question: retrieving values of variables through C API

2007-05-17 Thread joshusdog
I've got an application that embeds the Python interpreter. I have the
following command in my code:

   PyRun_SimpleString("a = \"hello\"");

My question is, what is the C API function call for retrieving the
value of the variable "a"?

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


unhandled exception question

2007-05-25 Thread joshusdog
I'm working on a test application that embeds the Python interpreter.
I have the following problem...

I've created my own interactive interpreter loop. Essentially, it
reads the command from the prompt and calls the following C code:

PyObject* pMainModule = PyImport_AddModule("__main__");
PyObject* pMainDictionary = PyModule_GetDict(pMainModule);
PyObject* pObj = PyRun_String(pCommandText, Py_single_input,
pMainDictionary, pMainDictionary);

where pCommandText is the text entered by the user.

I also have the following Python functions defined:

def Boo():
raise Exception()

def Foo():
try:
MyModule.SomeFunction()
except Exception:
print "goodbye"

MyModule.SomeFunction() is defined in C. All it does is call Boo()
with the following code:

PyObject* pMainModule = PyImport_AddModule("__main__");
PyObject* pMainDictionary = PyModule_GetDict(pMainModule);
PyObject* pObj = PyRun_String("Boo()", Py_single_input,
pMainDictionary, pMainDictionary);

If it's at all relevent, I'm using Boost.Python to embed MyModule.

Now here's the problem: when I type "Foo()" at the prompt, it calls
Foo(), which calls MyModule.SomeFunction(), which calls Boo(), which
raises the exception. However, the exception doesn't get handled,
despite the try-except statement in Foo(). Even stranger, if I
manually enter the entire multi-line try-except statement at the
prompt (instead of simply calling Foo()), the exception is handled
properly and "goodbye" is printed to the screen.

What's going on here? Why is exception properly handled in the second
case, but not the first?

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


help building debug .pyd files

2007-04-11 Thread joshusdog
The installation of Python 2.5 comes with a bunch of built-in
extension modules (.pyd files) under the DLLs directory. I've
downloaded the Python source code and am trying to build the debug
versions of all of these files. However, some of the projects won't
build because they are looking for header files that don't exist
anywhere. Specifically, the non-building projects are:

_bsddb
_sqlite3
_ssl
_tkinter
bz2

Additionally, the project for the _hashlib module seems to be entirely
missing from the Python source. Any idea where I can find it?

Is there a set of pre-built debug versions of all of these modules I
can download somewhere? It would save me a lot of time trying to
figure out where all these missing files are supposed to come from...

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