Sublime Forum

Output Panel Not Displayed

#1

Hi,
My plugin does some processing that take a few seconds to complete. I thought it would be a good idea to pop up a message while the processing was in progress so it wouldn’t look like things were hung . Nothing fancy, just some static text on a panel:

new_file = view.window().new_file()
               
progress_panel = new_file.window().create_output_panel('progress_panel')
progress_panel.run_command("append", {"characters": "Converting file. Please wait..."})
                
new_file.window().run_command('show_panel', {'panel':'output.progress_panel'})
... wait for processing to complete; around 5 seconds or so....
new_file.window().run_command('hide_panel', {'panel':'output.progress_panel'})

The code runs with no errors, but I don’t get a output panel. Seems like pretty straightforward implementation, so I’m not sure where I’m going wrong. Any insight is appreciated.

0 Likes

#2

hmm, manually running your code from the ST console works as expected.

Maybe you need to use a different thread or something so that the UI will get updated before the command completes…

try

sublime.set_timeout_async(lambda: new_file.window().run_command('show_panel', {'panel':'output.progress_panel'}), 0)
0 Likes

#3

I think you better use the status bar…

0 Likes

#4

Yeah, the problem appears to be threading/blocking. I’m trying to display the panel just before doing some disk I/O and creating a new file/tab. If I comment out the method that goes to the drive, the panel shows just fine. Same thing with the quick panel and show_popup. Not sure if I want to get involved with threading just to popup a status message. But I certainly appreciate the help.:+1:

0 Likes

#5

I doubt that it’s relevant here, but as an aside if you were invoking this code as a result of an event call (like on_save or some such) you can get into a separate thread by just using the asynchronous version of the event handler instead.

1 Like

#6

Changing the plugin to use the async version of the load event worked :+1: Thanks for the tip!

1 Like