Sublime Forum

Update contents of quick panel

#1

I have two questions about quick panel API in Sublime Text 2.

  1. How can I update the items being shown in quick panel

Say for example, I am using the following command to display the contents of list/array itemsList in quick panel.

self.window.show_quick_panel(itemsList, self.on_done)

I want that when the contents of itemsList are changed, the contents being shown in quick panel should change.
What I am doing right now is when the list itemsList is updated, I call show_quick_panel once again to show the new contents, but what that does is it opens two quick panels. Hence my question that how can I update the quick panel to show contents of itemsList here.

  1. In case contents cannot be updated, can I close the quick panel programmatically?
1 Like

#2

Here is a quick example to do what you want:

temp = "1", "2", "3", "4"]
def add_update():
	if len(temp) < 10:
		temp.append("5")
		self.window.run_command("hide_overlay")
		self.window.show_quick_panel(temp, None)
		sublime.set_timeout(add_update, 1000)
sublime.set_timeout(add_update, 1000)

Disclaimer: I have just looked at Sublime’s API for an hour or so, and I haven’t done Python before.

0 Likes