I am working on a plugin and would like to write messages to the output panel, rather than the console with the "print" command. Searching the forums I found out that this has been asked before and was resolved by using the build commands, but in my case I don't think that will work. Is there any way to write to the output panel from a python plugin? Thanks!

There isn't a way to do this yet, but 20090922 does introduce a new feature of scratch buffers - if you create a new buffer, and call view.isScratch(True), then it'll be a more appropriate place to send plugin output: the user won't get prompted to save it.

Thanks for the response and the scratch buffer is cool, but not quite what I had in mind for output. Really I am just looking for a way to display results just as it is in the console or output panel. Console is actually fine, it's just that there is quite a bit of other things being printed there and it would be nice to have a clean panel to send plugin output to.

I tried the scratch panel setting(with beta 20090923) but it didn't seem to work. Here is the python

mikeb wrote:Thanks for the response and the scratch buffer is cool, but not quite what I had in mind for output. Really I am just looking for a way to display results just as it is in the console or output panel. Console is actually fine, it's just that there is quite a bit of other things being printed there and it would be nice to have a clean panel to send plugin output to.

I tried the scratch panel setting(with beta 20090923) but it didn't seem to work. Here is the python

So I was able to get output printed to a scratch buffer and I can now see some real benefits to using them over the output panel or console and perhaps we don't even need a way to print to output console. One idea I am thinking about would be to create a syntax definition for the scratch buffer to make it more readable. My initial preference was just to be able to have an area at the bottom of the screen to display output and history... perhaps a new layout that had the a pane on bottom that spanned all vertical panes above might be a valuable layout to add and would serve the same purpose but also be tabbed, etc...

** A note for others that might be trying to do the same thing as me. results.setScratch(results.bufferId()) worked perfectly. In order to find the same panel on a second run of the plugin I had to set the name of the scratch buffer and then loop through the all the views and check the name of each one to find the same buffer on a second run of the plugin. I tried results = window.openFile(name) but it just said that it couldn't find the open file with that name, which might be a bug.

In order to find the same panel on a second run of the plugin I had to set the name of the scratch buffer and then loop through the all the views and check the name of each one to find the same buffer on a second run of the plugin.

You can keep the scratch buffer in a class variable:

EDIT: there's a problem with the code below: if the user closes the "My output" buffer, the plugin will not be aware of it and "self.Results in view.window().views()" always returns false