Skip to content

Instantly share code, notes, and snippets.

@matovitch
Created December 17, 2012 18:38
Show Gist options
  • Save matovitch/4320735 to your computer and use it in GitHub Desktop.
Save matovitch/4320735 to your computer and use it in GitHub Desktop.
Allow to get password in sublime text input panel. (ugly hack) First gist...first python day...How I lived before ?
import sublime, sublime_plugin
import subprocess
pwd = ""
class MePasswordCommand(sublime_plugin.WindowCommand):
def run(self):
self.window.show_input_panel("password", "", self.on_input, self.getpwd, None)
def getpwd(self, password):
global pwd
chg = password.replace("*", "")
if len(password) < len(pwd):
pwd = pwd[:len(password)]
else:
pwd = pwd + chg
stars = "*" * len(password)
self.window.show_input_panel("Project name", stars, self.on_input, self.getpwd, None)
def on_input(self, password):
global pwd
if pwd.strip() == "":
self.panel("No password provided")
return
#Do Something with pwd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment