i am working on file upload plugin…for now when the file is uploaded i am showing a dialogue box thatshows file is uploaded…but user needs to press ok every time…is there a method which shows custom text on the bottom panel(beside the monitor symbol where line number is shown)…i observe that package control can show a loader while installing a package… then i can also show it… but how?
When my plugin is running can i show some message or loader in the console panel
The bottom panel is called status bar. So, you can use sublime.status_message('my message')
, or view.set_status('my_plugin', 'my_message')
And what package control does is simply log plenty of status message. Because they erase the previous, you can do some cool stuff. Wait a sec, I’ll give you an example…
yes its working thank u…but how to make it look like a loader?and also continue with my upload simultaneously?do i need to use threads?
Sorry… Yep, you have to use threads (if you didn’t you’d freeze sublime text, so you loader wouldn’t be able to move…)
Here’s what I’ve done for fun:
# -*- encoding: utf-8 -*-
import sublime
import threading
class _Loader(threading.Thread):
def __init__(self, loading_message, final_message):
super().__init__()
self.pos = 0
self.length = 7
self.loading_message = loading_message
self.final_message = final_message
self.going = 1
def _go(self):
if self.going == 0:
return sublime.status_message(self.final_message)
msg = '[{}={}] {}'.format(' ' * self.pos, ' ' * (self.length - self.pos), self.loading_message)
self.pos += self.going
if self.pos >= self.length:
self.going = -1
if self.pos <= 0:
self.going = 1
sublime.status_message(msg)
sublime.set_timeout(self._go, 100)
def run(self):
sublime.set_timeout(self._go, 0)
class Loader:
def go(self, loading_message, final_message):
self.loader = _Loader(loading_message, final_message)
self.loader.start()
def stop(self):
self.loader.going = 0
self.loader.join()
loader = Loader()
loader.go('Looking good...', 'Done!')
sublime.set_timeout_async(lambda: loader.stop(), 5000)
But, the package control’s solution seems much better.
What about logging to console, or to a panel, rather than to the status-bar? Can’t find references for that
I believe the referenced file could belong to this tag, according to the publish date…:
Which maybe corresponds to this one in the current release:
Thanks for the hint!