Sublime Forum

Is there really no mechanism to get input in Sublime Text 3?

#1

I was going to write a plugin that prompted for an email address, then sent the current file via email. Then I learned that ST3 does not support getting input from a prompt. I’ve read some articles that indicate they are using SublimeREPL as a workaround.

Is it true that you cannot prompt for input in ST3? I just find this difficult to believe that something so important is missing from Sublime.

0 Likes

#2

You definitely can prompt for input, just to happens through the Sublime Text API. You’ll want to use the Window.show_input_panel() function.

What is not possible is to capture input via the stdin file handle of a script or program run through a build system.

2 Likes

#3

You can use the show_input_panel() method from the sublime.Window class to prompt the user for a line of text.

show_input_panel(caption, initial_text, on_done, on_change, on_cancel)

Shows the input panel, to collect a line of input from the user. on_done and on_change, if not None, should both be functions that expect a single string argument. on_cancel should be a function that expects no arguments. The view used for the input widget is returned.

2 Likes

#4

Thank you, that is a relief!

1 Like