Redirecting stdin, stdout, and stderr to a window

Discussion in 'Python' started by Michael McGarry, Dec 16, 2004.

  1. Hi,

    How do I redirect stdin, stdout and stderr to a window? I am using Qt
    for GUI.

    Thanks,

    Michael
     
    Michael McGarry, Dec 16, 2004
    #1
    1. Advertisements

  2. Michael McGarry

    Michael Fuhr Guest

    I don't know what specific mechanisms Qt provides, but the general
    solution is to write a class that implements I/O methods like read,
    readline, and write, and assign instances of that method to the
    input and output filehandles. For example, you could write a class
    with a write() method that displays text in a window, then assign
    an instance of that class to sys.stdout. Subsequent calls to 'print'
    would send output to the window.
     
    Michael Fuhr, Dec 16, 2004
    #2
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.