Skip to content

Instantly share code, notes, and snippets.

@fernandolopez
Created May 30, 2015 22:50
Show Gist options
  • Save fernandolopez/3084d6a9022174271c3a to your computer and use it in GitHub Desktop.
Save fernandolopez/3084d6a9022174271c3a to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
import sys
import subprocess
import functools
if sys.version_info.major == 2:
input = raw_input
class Dialog(object):
def call(self, type_, *args):
sp = subprocess.Popen(
['dialog', '--' + type_] + list(map(str, args)),
stderr=subprocess.PIPE,
)
_, stderr = sp.communicate()
if stderr == b'':
return sp.returncode == 0
return stderr
def __getattr__(self, attr):
return functools.partial(self.call, attr)
if __name__ == '__main__':
dialog = Dialog()
x = dialog.call('yesno', 'Hola', 0, 0)
print(x)
input('enter para seguir')
x = dialog.radiolist('Hi', 0, 0, 0,
'uno', 'Opción uno', 'on',
'dos', 'Opción dos', 'off')
print(x)
input('enter para seguir')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment