Hi guillermooo,
I've also been struggling with this for a few days and found that the following code solves the problem. I think there is some confusion introduced by the
window.get_output_panel function because of it's name. I discovered from a few simple tests that "
get_output_panel" should really be called "
create_output_panel" since it clobbers any text you've written to it before the call.
@jps Maybe this could be renamed in the API?
Cheers,
Josh
- Code: Select all
def append(self, text, panel_name = 'example'):
# get_output_panel doesn't "get" the panel, it *creates* it,
# so we should only call get_output_panel once
if not hasattr(self, 'output_view'):
self.output_view = self.window.get_output_panel(panel_name)
v = self.output_view
# Write this text to the output panel and display it
edit = v.begin_edit()
v.insert(edit, v.size(), text + '\n')
v.end_edit(edit)
v.show(v.size())
self.window.run_command("show_panel", {"panel": "output." + panel_name})