def get_from_user(title, prompt, hidden=False, value=None):
 if (value is None):
  value = ''
 script = '\n        on run argv\n          tell application "Alfred 2"\n              activate\n              set alfredPath to (path to application "Alfred 2")\n              set alfredIcon to path to resource "appicon.icns" in bundle \xc2\xac\n                (alfredPath as alias)\n\n              set dlgTitle to (item 1 of argv)\n              set dlgPrompt to (item 2 of argv)\n\n              if (count of argv) is 3\n                set dlgHidden to (item 3 of argv as boolean)\n              else\n                set dlgHidden to false\n              end if\n\n              if dlgHidden\n                display dialog dlgPrompt & ":" with title dlgTitle \xc2\xac\n                  default answer "{v}" with icon alfredIcon with hidden answer\n              else\n                display dialog dlgPrompt & ":" with title dlgTitle \xc2\xac\n                  default answer "{v}" with icon alfredIcon\n              end if\n\n              set answer to text returned of result\n          end tell\n        end run'.format(v=value)
 from subprocess import Popen, PIPE
 cmd = ['osascript', '-', title, prompt]
 if hidden:
  cmd.append('true')
 p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE)
 (stdout, stderr) = p.communicate(script)
 return stdout.rstrip('\n')

def get_from_user ( title , prompt , hidden = False , value = None ) : if ( value is None ) : value = '' script = '\n        on run argv\n          tell application "Alfred 2"\n              activate\n              set alfredPath to (path to application "Alfred 2")\n              set alfredIcon to path to resource "appicon.icns" in bundle \xc2\xac\n                (alfredPath as alias)\n\n              set dlgTitle to (item 1 of argv)\n              set dlgPrompt to (item 2 of argv)\n\n              if (count of argv) is 3\n                set dlgHidden to (item 3 of argv as boolean)\n              else\n                set dlgHidden to false\n              end if\n\n              if dlgHidden\n                display dialog dlgPrompt & ":" with title dlgTitle \xc2\xac\n                  default answer "{v}" with icon alfredIcon with hidden answer\n              else\n                display dialog dlgPrompt & ":" with title dlgTitle \xc2\xac\n                  default answer "{v}" with icon alfredIcon\n              end if\n\n              set answer to text returned of result\n          end tell\n        end run' . format ( v = value ) from subprocess import Popen , PIPE cmd = [ 'osascript' , '-' , title , prompt ] if hidden : cmd . append ( 'true' ) p = Popen ( cmd , stdin = PIPE , stdout = PIPE , stderr = PIPE ) ( stdout , stderr ) = p . communicate ( script ) return stdout . rstrip ( '\n' )
popup a dialog to request some piece of information .