+import subprocess
+
class Interface() :
def yesnoback(self, _strs) :
print("{}: {}".format(_str[0].ljust(25), _str[1]))
-
def choose(self, _num_of_choices) :
str = "\nChoose the item you want to change.({}-{}) > ".format(1, _num_of_choices)
print("")
return num
+class Zenity(CUI) :
+
+ def __init__(self) :
+
+ self.item_list = None
+
+ def yesnoback(self, _strs) :
+
+ str = ""
+
+ if len(_strs[0]) >= 2 :
+
+ for tmp in _strs :
+ str = str + "\n" + tmp
+
+ else :
+ str = _strs
+
+
+ ans = subprocess.call(["zenity", "--question", "--title=Serene Setup Wizard", "--text={}".format(str), "--width=300"], stderr=open("/dev/null", "w"))
+
+ if ans == 0 :
+ return True
+ else :
+ return False
+
+
+ def show(self, _str) :
+
+ if self.item_list is None :
+
+ self.item_list = list()
+
+ self.item_list.append(_str)
+
+
+ def choose(self, _) :
+
+ str = ["zenity", "--list", "--title=Serene Setup Wizard", "--text", "Choose the item you want to change.", "--height=400", "--width=400", "--column", "No.", "--column", "Item", "--column", "Status", "--print-column=all"]
+
+
+ for i, item in enumerate(self.item_list) :
+
+ str.append("{}".format(i+1))
+ str.append("{}".format(item[0]))
+ str.append("{}".format(item[1]))
+
+ self.item_list = None
+
+ while True :
+
+ tmp = open("/tmp/serene-setup-wizard.tmp", "w")
+ ret = subprocess.call(str, stdout=tmp, stderr=open("/dev/null", "w"))
+ tmp.close()
+
+ if ret :
+ print("")
+ return False
+
+ tmp = open("/tmp/serene-setup-wizard.tmp", "r")
+ ans = tmp.readline().split("|")[0]
+ tmp.close()
+
+ if ans != "" :
+ break
+
+ print("")
+ return int(ans)
+