Sublime Forum

Help with plugin using an input panel AND an output panel

#1

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:

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

1 Like