import sublime, sublime_plugin
import threading
import time

# This is the primary command which executes everything else
class TestCommand( sublime_plugin.TextCommand ):
    def run( self, edit ):

        global progress_Index, progress_MaxIndex
        progress_Index    = 0
        progress_MaxIndex = 100

        self.view.show_popup( str( 0 ) )

        # this loop is representative of a single script executing
        # with various progress updates throughout its execution
        for index in range( 0, 10 ):
            time.sleep( 0.2 )
            start_thread()

def start_thread():
    thread = ProgressBarThread( view )
    thread.start()

class ProgressBarThread( threading.Thread ):
    def run( self ):
        sublime.active_window().active_view().run_command( "update_progress_bar" )

# This updates the global progress data & prints current values to the PopUp
class UpdateProgressBarCommand( sublime_plugin.TextCommand ):
    def run( self, edit ):

        global progress_Index, progress_MaxIndex

        progress_Index += 10

        if progress_Index > progress_MaxIndex:
            return
        else:
            progress_String = str( progress_Index )
            self.view.update_popup( progress_String )