1

I have the following code:

self.report({'INFO'}, 'a\nb\nc')
self.report({'INFO'}, '0\n1\n2')

In the info view the output is displayed as:

c
b
a
2
1
0

Is it possible to configure the Info view to display it in a normal way, like:

a
b
c
0
1
2
zeffii
  • 39,634
  • 9
  • 103
  • 186
Endre
  • 269
  • 2
  • 5
  • 1
    You shouldn't call report() twice under normal circumstances. – CodeManX Jul 17 '15 at 08:45
  • I'd like some terminal like window for debug messages. Is there any other way? Launching blender from terminal is not an option, since I have single monitor configuration and it is unconvenient to switch between windows. – Endre Jul 17 '15 at 09:33
  • 1
    I place the console and Blender side by side, works for me. You could also push to the Python console, or use a draw handler to overlay information in the 3d view. – CodeManX Jul 17 '15 at 10:19

1 Answers1

2

This could be used, but i'm sure i'll receive some heat for suggesting this. Run this from text editor, and it will print 'wooot' in the first available blender Python Console.

import bpy

# doesn't support passing the context
# from console_python import add_scrollback

def add_scrollback2(ctx, text, text_type):
    for l in text.split("\n"):
        bpy.ops.console.scrollback_append(ctx, text=l.replace("\t", "    "),
                                          type=text_type)

for area in bpy.context.screen.areas:
    if area.type == 'CONSOLE':

        ctx = bpy.context.copy()
        ctx['area'] = area
        add_scrollback2(ctx, "whooot", 'INFO')
        break

A few caveats, this isn't recommended at all, and especially not for printing out large chunks of data rapidly. That's what logging is for, you can write output to text files on disk, much much faster than your machine can print messages to the screen (printing to screen slows down your code significantly if it happens in tight loops). The benefit of writing to disk is you have virtually no limit regarding the amount of lines you can record, unlike most terminals/consoles which have a finite scroll-back buffer.

In the long run most of us conclude that it's more convenient to have a console/terminal open in addition to blender, be it landscape or portrait. This means starting Blender from a console, or creating a start-up shortcut that first spawns a console and then from that console an instance of blender.

If you do use regular terminal / console then be selective about what information you print, and avoid print statements that might be triggered in tight loops.

zeffii
  • 39,634
  • 9
  • 103
  • 186