Home Download Buy Blog Forum Support

Pass a function to a TextCommand plugin?

Re: Pass a function to a TextCommand plugin?

Postby kefka0 on Wed Oct 26, 2011 11:40 pm

facelessuser wrote:Spent about 15 minutes doing a little research. This opens an input panel and takes a string. It then displays says hello to whatever input you give it in the status bar.

Code: Select all
import sublime
import sublime_plugin


def display_hello(value):
    sublime.active_window().active_view().set_status("hello", "Hello " + value + "!")


class HelloWorldCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        self.view.window().show_input_panel(
            "Hello:",
            "World",
            display_hello,
            None,
            None
        )


Thanks man! I've got it working. I may package this up and post it on announcements...but then again maybe not, its very hacky and dangerous because it uses exec()
kefka0
 
Posts: 11
Joined: Wed Aug 17, 2011 11:20 pm

Previous

Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 5 guests