Created
May 30, 2015 22:50
-
-
Save fernandolopez/3084d6a9022174271c3a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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