本文整理汇总了Python中dialog.Dialog.buildlist方法的典型用法代码示例。如果您正苦于以下问题:Python Dialog.buildlist方法的具体用法?Python Dialog.buildlist怎么用?Python Dialog.buildlist使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dialog.Dialog
的用法示例。
在下文中一共展示了Dialog.buildlist方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DialogUtil
# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import buildlist [as 别名]
class DialogUtil(object):
"""Create dialog checklist
"""
def __init__(self, *args):
try:
from dialog import Dialog
except ImportError:
print("Require 'pythondialog': Install with '# slpkg -s sbo "
"python2-pythondialog'")
raise SystemExit()
self.d = Dialog(dialog="dialog", autowidgetsize=True)
self.data = args[0]
self.text = args[1]
self.title = args[2]
self.backtitle = args[3]
self.status = args[4]
self.ununicode = []
self.tags = []
def checklist(self):
"""Run dialog checklist
"""
choice = []
for item in self.data:
choice.append((item, "", self.status))
code, self.tags = self.d.checklist(
text=self.text, height=20, width=65, list_height=13,
choices=choice, title=self.title, backtitle=self.backtitle)
if code == "ok":
self.unicode_to_string()
return self.ununicode
if code in ["cancel", "esc"]:
self.exit()
def buildlist(self, enabled):
"""Run dialog buildlist
"""
choice = []
for item in self.data:
choice.append((item, False))
for item in enabled:
choice.append((item, True))
items = [(tag, tag, sta) for (tag, sta) in choice]
code, self.tags = self.d.buildlist(
text=self.text, items=items, visit_items=True, item_help=False,
title=self.title)
if code == "ok":
self.unicode_to_string()
return self.ununicode
if code in ["cancel", "esc"]:
self.exit()
def exit(self):
"""Exit from dialog
"""
self.clear_screen()
raise SystemExit()
def clear_screen(self):
"""Clear screen
"""
os.system("clear")
def unicode_to_string(self):
"""Convert unicode in string
"""
for tag in self.tags:
self.ununicode.append(str(tag))