I am trying to create a Sublime Text 3 plugin which writes output to an output panel in the current window. I have found a number of examples doing this using begin_edit and end_edit, which are no longer supported in ST3. To my understanding, ST3 requires that I define a TextCommand to support the editing action on my output panel. So far, what I have is this:
class SfprintCommand(sublime_plugin.TextCommand):
def run(self, edit):
self.view.insert(edit, self.view.size(), 'hello')
class SfCommand(sublime_plugin.TextCommand):
def run(self, edit):
self.panel = self.view.window().create_output_panel('sf_st3_output')
self.view.window().run_command('show_panel', { 'panel': 'output.sf_st3_output' })
self.panel.run_command('sfprint');
I would expect that this should print the text "hello" in my output panel, but when I try to invoke this through the console (by running view.run_command('sf')
), this displays the new panel but does not print any information to it. How can I write text to this panel?
In order for taking input and receiving output from a code, we need to manually set up our input and output files. Step 1: From the top menu, select View->Layout->Columns :3 or press Shift+Alt+3. Step 2: Now select View->Groups->Max columns: 2. Step 3: Now you can view three files simultaneously in sublime text.
This question is specifically about displaying the output of the python code in the build results window. Super+Shift+B is the right answer. It is not a duplicate of the other question, but an extension of it.
Save this answer. Show activity on this post. In Sublime 2, in order to call up the build results window you can use the Tools > Build Results > Show Build Results menu item.
Use Alt+Shift+P to print. My favorite tool for printing from Sublime Text is Print to HTML package. You can "print" a selection or a whole file - via the web browser.
After restarting everything, the same code seems to be working now. My lesson learned: apparently it's best not too put too much faith into ST3's hot plugin reloading!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With