Ignore:
Timestamp:
01/11/13 17:15:19 (15 months ago)
Author:
Ales Erjavec <ales.erjavec@…>
Branch:
default
Message:

Added colored/formated output for the stdout/err output, output thread safety.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Orange/OrangeCanvas/main.py

    r11256 r11257  
    2121from Orange.OrangeCanvas.application.application import CanvasApplication 
    2222from Orange.OrangeCanvas.application.canvasmain import CanvasMainWindow 
     23from Orange.OrangeCanvas.application.outputview import TextStream 
    2324 
    2425from Orange.OrangeCanvas.gui.splashscreen import SplashScreen, QPixmap 
     
    235236        settings.value("output/redirect-stderr", True).toBool() 
    236237 
    237     # cmd line option overrides settings, and not redirect possible 
     238    # cmd line option overrides settings / no redirect is possible 
    238239    # under ipython 
    239240    if options.no_redirect or running_in_ipython(): 
     
    243244 
    244245    if stdout_redirect: 
    245         stdout = output_view 
     246        stdout = TextStream() 
     247        stdout.stream.connect(output_view.write) 
     248        # also connect to original fd 
     249        stdout.stream.connect(sys.stdout.write) 
    246250    else: 
    247251        stdout = sys.stdout 
    248252 
    249253    if stderr_redirect: 
    250         stderr = output_view 
     254        error_writer = output_view.formated(color=Qt.red) 
     255        stderr = TextStream() 
     256        stderr.stream.connect(error_writer.write) 
     257        # also connect to original fd 
     258        stderr.stream.connect(sys.stderr.write) 
    251259    else: 
    252260        stderr = sys.stderr 
Note: See TracChangeset for help on using the changeset viewer.