dual text + button input

This commit is contained in:
j 2019-01-24 12:47:00 +05:30
commit de67f202a8
2 changed files with 39 additions and 14 deletions

View file

@ -40,6 +40,8 @@ def selectFolder(data):
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, close_fds=True)
stdout, stderr = p.communicate()
path = stdout.decode('utf-8').strip()
if path == 'None':
path = None
return {
'path': path
}
@ -60,12 +62,18 @@ def selectFile(data):
p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
stdout, stderr = p.communicate()
path = stdout.decode('utf-8').strip()
if path == 'None':
path = None
return {
'path': path
}
actions.register(selectFile, cache=False)
def short_home(path):
home = os.path.expanduser('~')
if path and path.startswith(home):
path = path.replace(home, '~')
return path
def autocompleteFolder(data):
'''
@ -92,6 +100,7 @@ def autocompleteFolder(data):
folders = [path] + folders
else:
folders = []
folders = [short_home(f) for f in folders]
return {
'items': ox.sorted_strings(folders)
}