Interactive Console for Win32 Application

D

Devrim Erdem

Hello,

I am on win32 with python2.2.

My python added C++ app is an OpenGL application so there is no real
GUI code around it. I have built in the python interpreter which works
very great. I would like to have the opportunity to popup a console
from my application which has access to the python module which is
defined and instantiated in my application.

If I had the time, I would implement a Quake like console. To save
time, I wanted to check if there is already a way of doing this on
Windows.

P.S. The app is not full screen so I can popup another window that's
not a problem at all.

Thanks in advance,

Devrim
 
F

Fredrik Lundh

Devrim said:
I am on win32 with python2.2.

My python added C++ app is an OpenGL application so there is no real
GUI code around it. I have built in the python interpreter which works
very great. I would like to have the opportunity to popup a console
from my application which has access to the python module which is
defined and instantiated in my application.

If I had the time, I would implement a Quake like console. To save
time, I wanted to check if there is already a way of doing this on
Windows.

I'll leave it to you to write the code that reads a line from the user, but
once you have that in place, the "code" module provides the rest:

http://www.python.org/doc/current/lib/module-code.html

outline:

console = code.InteractiveConsole()

myconsole = DisplayMyConsole(callback=console.push)
sys.stdout = myconsole.get_output_handler(WHITE)
sys.stderr = myconsole.get_output_handler(RED)
myconsole.enter_event_loop()

(where the callback argument is called whenever the user enters a new
line, and get_output_handler returns a file-like object that prints to the
console window (it must implement a "write" method, but that's about
it).

</F>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top