Interactive Console for Win32 Application

Discussion in 'Python' started by Devrim Erdem, Sep 19, 2004.

  1. Devrim Erdem

    Devrim Erdem Guest

    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
    Devrim Erdem, Sep 19, 2004
    #1
    1. Advertising

  2. Devrim Erdem wrote:

    > 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>
    Fredrik Lundh, Sep 19, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. WJ
    Replies:
    2
    Views:
    473
  2. Oleg  Konovalov

    Interactive console using Swing

    Oleg Konovalov, May 24, 2004, in forum: Java
    Replies:
    2
    Views:
    1,729
    Hal Rosser
    Jun 1, 2004
  3. Lee Harr
    Replies:
    0
    Views:
    370
    Lee Harr
    Aug 6, 2003
  4. Thomas Heller

    Re: Interactive Console in embedded Python

    Thomas Heller, Aug 6, 2003, in forum: Python
    Replies:
    0
    Views:
    433
    Thomas Heller
    Aug 6, 2003
  5. Paul Miller

    embedding an interactive console

    Paul Miller, Apr 28, 2005, in forum: Python
    Replies:
    1
    Views:
    419
    Paul Miller
    Apr 28, 2005
Loading...

Share This Page