1. Briefly
I don't find, how I can get output in new view, not in Sublime Text console.
2. Expected behavior
For example, I have countdown timer:
import time
seconds = 10
while seconds >= 0:
time.sleep(1)
if seconds == 5:
print("5 seconds")
elif seconds == 0:
print("Time over!")
time.sleep(5)
else:
print(seconds)
seconds -= 1
Ctrl+Shift+P (⌘⇧p for Mac) → SublimeREPL: Python RUN current file
→ I get expected behavior:
3. Actual behavior
Same countdown timer in Sublime Text plugin:
import time
import sublime_plugin
seconds = 10
class LovernaStandardCommand(sublime_plugin.TextCommand):
def run(self, edit):
current_id = self.view.id()
if current_id:
global seconds
while seconds >= 0:
time.sleep(1)
if seconds == 5:
print("5 seconds")
elif seconds == 0:
print("Time over!")
time.sleep(5)
else:
print(seconds)
seconds -= 1
I run command loverna_standard
→ I see output in Sublime Text console, not in new view.
4. Not helped
- Python write() method works with files, not with unsaved buffers.
- I find in Sublime Text 3 API documentation, how I can open new view —
sublime.active_window().new_file()
— but I don't find, how I can print text in this view.