Home Download Buy Blog Forum Support

Help with plugin using an input panel AND an output panel

Help with plugin using an input panel AND an output panel

Postby jbjornson on Tue Mar 22, 2011 5:42 pm

Hi,

I'm trying to create a plugin that will take some user input (via window.show_input_panel), do some processing, and then provide some feedback to the user in an output panel (using window.get_output_panel). For some reason I can't seem to get the two of these panels to play nice with each other. I have been able to reproduce the problem in a pretty simple example plugin:

Code: Select all
import sublime, sublime_plugin

class ExampleCommand(sublime_plugin.WindowCommand):
    def run(self):
        # open an input box for some user input
        self.window.show_input_panel("Please enter a comment:", '', lambda s: self.set_user_input(s), None, None)

    def set_user_input(self, text):
        # now try to write this text to the panel
        panel_name = 'example'
        v = self.window.get_output_panel(panel_name)
        edit = v.begin_edit()
        v.insert(edit, v.size(), text)
        v.end_edit(edit)
        self.window.run_command("show_panel", {"panel": "output." + panel_name})


Edit: This example plugin will show the input panel, but will not display the output panel afterwards, even though the code is executed. If you don't show the input panel and just call "set_user_input", the output panel *will* be shown. Somehow by showing the input panel it seems like the output panel is being blocked.

Any ideas how to make something like this work? Although I am a developer by trade, I am pretty new to Python so may be making some fundamental mistake here.

Any help would be greatly appreciated.

Thanks,

Josh
jbjornson
 
Posts: 350
Joined: Tue Oct 27, 2009 4:25 pm
Location: Zurich, Switzerland

Return to Technical Support

Who is online

Users browsing this forum: No registered users and 19 guests