Home Download Buy Blog Forum Support

Updating the quick panel

Updating the quick panel

Postby Marciano on Sat Feb 27, 2010 10:26 pm

I'm trying to learn how to update the quick panel. Here's a simple example:
Code: Select all
class PanelTestCommand(sublimeplugin.WindowCommand):
   def run(self, window, args):
      args = ["wait 5 seconds..."]
      window.showQuickPanel("", "", args)
      print "Wait"
      import time
      time.sleep(5)
      args.append("Done!")
      print "Done"
      window.showQuickPanel("update", "", args)


I'm not sure how the first parameter, called "key" in the docs, actually does. My understanding is that if it's not blank, the panel gets updated, but I'm not sure.

Anyway, the problem is that it looks like both output to the output panel and updates to the quick panel are buffered. The net result is that, when I invoke the above code using

Code: Select all
window.runCommand("panelTest")


nothing happens for 5 seconds, and then (1) the two lines of text are shown in the output panel, and (2) the quick panel pops up, again showing both lines of text.

I'm probably doing something really silly, but I'm running out of ideas. Anyone? Thanks! M
Marciano
 
Posts: 143
Joined: Fri Sep 18, 2009 2:55 am

Re: Updating the quick panel

Postby jps on Sun Feb 28, 2010 9:56 pm

If you're specifying a key, you'll need to specify the same key both when initially showing the quick panel and when updating it. The basic logic is that when calling the showQuickPanel function, if the key matches the key of the existing quick panel, then it's updated rather than reset (i.e., the selected item and entered text is preserved).

To delay processing in an plugin, rather than calling sleep(), which blocks the editor, use sublime.setTimeout().
jps
Site Admin
 
Posts: 3058
Joined: Wed Mar 19, 2008 12:33 pm

Re: Updating the quick panel

Postby Marciano on Mon Mar 01, 2010 12:25 am

OK, thanks for clarifying the use of the "key" parameter.

Regarding the "sleep" function, that was just an example. What I really want to do is show some text in the quick panel ("Compiling..."), launch a command-line tool via subprocess.Popen, and then show the result of compilation in the same quick panel. That, too, seems to be blocking: the quick panel comes up only when compilation ends, which is not what I want. Thanks! M
Marciano
 
Posts: 143
Joined: Fri Sep 18, 2009 2:55 am

Re: Updating the quick panel

Postby Marciano on Mon Mar 01, 2010 5:33 am

Ah! Thanks a lot. I'll try to figure it out. I did notice the generator tricks in AAA*, but did not ponder the issue long enough to understand how it works. Too bad the week-end is over here in Chicago :-(
Marciano
 
Posts: 143
Joined: Fri Sep 18, 2009 2:55 am

Re: Updating the quick panel

Postby Marciano on Mon Mar 01, 2010 2:08 pm

Hi, and thanks again,

any further info (even half-baked html!) would be very welcome :-) If you don't feel like posting it, you could email it to me at msiniscalchi shift-2 gmail dot com. Thanks!

Best---M
Marciano
 
Posts: 143
Joined: Fri Sep 18, 2009 2:55 am

Re: Updating the quick panel

Postby jps on Mon Mar 01, 2010 9:13 pm

Marciano wrote:What I really want to do is show some text in the quick panel ("Compiling..."), launch a command-line tool via subprocess.Popen, and then show the result of compilation in the same quick panel.


It sounds like you should be creating a thread to launch the command line tool, and block on receiving the output there. When you've got the results, send them back to the main thread via setTimeout (setTimeout is the only API function safe to call from another thread).
jps
Site Admin
 
Posts: 3058
Joined: Wed Mar 19, 2008 12:33 pm

Re: Updating the quick panel

Postby Marciano on Sat Jun 05, 2010 4:49 am

I updated the LaTeX plugin following jps's advice---thanks! For the possible benefit of other plugin authors, I documented my learning experience on my blog:

http://tekonomist.wordpress.com/2010/06 ... nd-profit/

I'm pretty sure I got a few things wrong; if so, please let me know. Thanks!
Marciano
 
Posts: 143
Joined: Fri Sep 18, 2009 2:55 am


Return to Technical Support

Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 7 guests

cron