当前位置: 首页>>代码示例>>Python>>正文


Python Dialog.checklist方法代码示例

本文整理汇总了Python中dialog.Dialog.checklist方法的典型用法代码示例。如果您正苦于以下问题:Python Dialog.checklist方法的具体用法?Python Dialog.checklist怎么用?Python Dialog.checklist使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dialog.Dialog的用法示例。


在下文中一共展示了Dialog.checklist方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: choose_cols

# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import checklist [as 别名]
 def choose_cols(self):
     # XX possibility un/check all
     chosens = [(str(i + 1), f, i in self.csv.settings["chosen_cols"]) for i, f in enumerate(self.csv.fields)]
     d = Dialog(autowidgetsize=True)
     ret, values = d.checklist("What fields should be included in the output file?",
                               choices=chosens)
     if ret == "ok":
         self.csv.settings["chosen_cols"] = [int(v) - 1 for v in values]
         self.csv.is_processable = True
开发者ID:CZ-NIC,项目名称:convey,代码行数:11,代码来源:controller.py

示例2: ask

# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import checklist [as 别名]
 def ask(self):
     if hasattr(self.port, 'config'):
         dialog = Dialog(dialog='dialog')
         dialog.set_background_title('Conguration for {PORTNAME}'.format(PORTNAME=self.port.portname))
         portchoices = []
         for option, optvalues in self.port.config.items():
             self.port.config[option]['user_choice'] = False
             portchoices.append((option, optvalues['description'], optvalues['default']))
         code, tags = dialog.checklist(
             'Choose your Configuration for {PORTNAME}'.format(PORTNAME=self.port.portname),
             choices=portchoices, title="Port configuration")
         if code == dialog.OK:
             for tag in tags:
                 self.port.config[tag]['user_choice'] = True
         print('\n')
开发者ID:Toasterson,项目名称:port,代码行数:17,代码来源:build.py

示例3: DialogUtil

# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import checklist [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))
开发者ID:fabioalvaro,项目名称:slpkg,代码行数:70,代码来源:dialog_box.py

示例4: WindowsInstallApp

# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import checklist [as 别名]
class WindowsInstallApp(object):
    def __init__(self, config=None):
        self.logger = logging.getLogger(__name__)
        self.config = config

        self.uefi = False

        self.boot_part = ''
        self.system_part = ''
        self.image_path = ''
        self.image_index = ''

        self.boot_dir = '/mnt/boot'
        self.system_dir = '/mnt/system'

        self.mbr_disk_signature = '4D34B30F'
        self.gpt_disk_signature = '572BD0E9-D39E-422C-82E6-F37157C3535D'
        self.boot_partuuid = '8d03c7bb-6b0c-4223-aaa1-f20bf521cd6e'
        self.system_partuuid = '57092450-f142-4749-b540-f2ec0a183b7b'

        self.cluster_size = 4096
        self.fs_compression = False
        self.quick_format = True

        self.d = Dialog(dialog='dialog')
        self.d.set_background_title('KiWI: Killer Windows Installer')

        self.source_dir = '/mnt/source/'

        advanced_items = [
            ('Filesystem options', MenuItem(self.fs_options)),
        ]

        advanced_submenu = Menu(self.d, advanced_items, title='Advanced Options')

        main_menu_items = [
            ('Configure Networking', MenuItem(self.configure_network)),
            ('Prepare Storage Device', MenuItem(self.auto_prepare)),
            ('Select Installation Source', MenuItem(self.prepare_source)),
            ('Install OS', MenuItem(self.install_os)),
            #('Install Bootloader', self.install_bootloader),
            ('Reboot', MenuItem(self.reboot)),
            ('---', MenuItem(separator=True)),
            ('Advanced Options', advanced_submenu),
        ]

        self.running = True
        self.main_menu = StatefulMenu(self.d, main_menu_items, title='Main Menu')
        while self.running: self.main_menu.run(ret=self.exit())

    def sync(self):
        self.d.infobox('Syncing buffered data\n\nDo NOT reboot!', width=30)
        subprocess.check_call(['sync'])

    def reboot(self):
        self.sync()
        subprocess.check_call(['reboot'])

    def fs_options(self):
        choices = [
            ('Quick Format',        '',             'quick_format'),
            ('NTFS Compression',    '',             'fs_compression'),
            ('Force GPT/EFI',       '',             'uefi'),
        ]

        code, selected = self.d.checklist('Filesystem Options', choices=[
            (choice[0], choice[1], getattr(self, choice[2])) for choice in choices],
            cancel_label='Back')

        if code != self.d.OK: return

        for item in choices:
            tag = item[0]
            var_name = item[2]

            if tag in selected: setattr(self, var_name, True)
            else: setattr(self, var_name, False)

    def test_network(self):
        return True if subprocess.call(
            ['ping', '-c 2', '-i 0.2', '8.8.8.8'],
            stdout=subprocess.PIPE) == 0 else False

    def configure_network(self):
        if not self.test_network():
            rc = subprocess.call('nmtui', shell=True)
        else:
            self.d.msgbox('Network Configuration Successful', width=40, title='Network Status')
            self.main_menu.advance()

    def detect_blockdevs(self):
        devices = []
        p = subprocess.run(['lsblk', '-Ppd'], stdout=subprocess.PIPE)
        for line in p.stdout.decode('UTF-8').split('\n'):
            dev = {}
            for p in line.split():
                pair = p.split('=')
                dev[pair[0]] = pair[1][1:-1]

            # We don't need read-only devices
#.........这里部分代码省略.........
开发者ID:jakogut,项目名称:KiWI,代码行数:103,代码来源:install.py

示例5: commandline

# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import checklist [as 别名]
def commandline():

  TXT_WELCOME_TITLE = 'Yet Another Common Criteria Parser and Checklist Generator!\n\nThis tool helps you to generate a quick workunit checklist.\n\nUse by your own risk'

  locale.setlocale(locale.LC_ALL, '')
  # You may want to use 'autowidgetsize=True' here (requires pythondialog >= 3.1)
  d = Dialog(dialog="dialog")
  #d = Dialog(dialog='dialog', autowidgetsize=True)
  # Dialog.set_background_title() requires pythondialog 2.13 or later
  d.set_background_title(TXT_WELCOME_TITLE)
  # For older versions, you can use:
  #   d.add_persistent_args(["--backtitle", "My little program"])

  # In pythondialog 3.x, you can compare the return code to d.OK, Dialog.OK or
  # "ok" (same object). In pythondialog 2.x, you have to use d.DIALOG_OK, which
  # is deprecated since version 3.0.0.
  code = d.yesno(TXT_WELCOME_TITLE, 
                  height="15", width="65", yes_label="OK", no_label="Cancel")

  if (code == Dialog.CANCEL or code == Dialog.ESC):
    clearquit()

  else:
    code, tag = d.menu("OK, then you have four options:",
                       choices=[("(1)", "Parse CC into a Database"),
                                ("(2)", "Export CC"),
                                ("(3)", "Parse and Export"),
                                ("(4)", "Generate Checklist")])
    if code == d.OK:
      if tag == "(1)":
        os.system('clear')
        if not (os.path.isfile("doc/cc3R4.xml")):
          d.msgbox("Error loading cc3R4.xml",height="10", width="45")
          sys.exit(1)
        os.system("python CCParser.py -ask doc/cc3R4.xml")
        d.msgbox("Generated database in data/ccdb.sqlite3",height="10", width="45")
        quit()

      elif tag == "(2)":
        os.system('clear')
        if not (os.path.isfile("data/ccdb.sqlite3")):
          d.msgbox("Error loading database. Must run CCParser.py first",height="10", width="45")
          sys.exit(1)
        os.system("python CChtmlExport.py -ask data/ccdb.sqlite3") 
        d.msgbox("Generated export in output/",height="10", width="45")
        quit()

      elif tag == "(3)":
        os.system('clear')
        if not (os.path.isfile("doc/cc3R4.xml")):
          d.msgbox("Error loading cc3R4.xml",height="10", width="45")
          sys.exit(1)
        os.system("python CCParser.py doc/cc3R4.xml && python CChtmlExport.py -ask data/ccdb.sqlite3") 
        d.msgbox("Generated database in data/ccdb.sqlite3 and export in output/",height="10", width="75")
        quit()

      elif tag == "(4)":
        if not (os.path.isfile("data/ccdb.sqlite3")):
          d.msgbox("Error loading database. Must run CCParser.py first",height="10", width="45")
          sys.exit(1)

        code, tag = d.menu("Evaluation Assurance Level:",
                           choices=[("(EAL1)", "Evaluation Assurance Level 1"),
                                    ("(EAL2)", "Evaluation Assurance Level 2"),
                                    ("(EAL3)", "Evaluation Assurance Level 3"),
                                    ("(EAL4)", "Evaluation Assurance Level 4"),
                                    ("(EAL5)", "Evaluation Assurance Level 5"),
                                    ("(EAL6)", "Evaluation Assurance Level 6"),
                                    ("(EAL7)", "Evaluation Assurance Level 7")])

        if code == d.OK:

          if tag == "(EAL1)": EALSELECTED = "EAL1"
          if tag == "(EAL2)": EALSELECTED = "EAL2"
          if tag == "(EAL3)": EALSELECTED = "EAL3"
          if tag == "(EAL4)": EALSELECTED = "EAL4"
          if tag == "(EAL5)": EALSELECTED = "EAL5"
          if tag == "(EAL6)": EALSELECTED = "EAL6"
          if tag == "(EAL7)": EALSELECTED = "EAL7"
     
          code, tags = d.checklist("Family",
                                   choices=[("ACO_DEV.1", "", False),
                                            ("ACO_DEV.2", "", False),
                                            ("ACO_DEV.3", "", False),
                                            ("ACO_REL.1", "", False),
                                            ("ACO_REL.2", "", False),
                                            ("ACO_CTT.1", "", False),
                                            ("ACO_CTT.2", "", False),
                                            ("ACO_VUL.1", "", False),
                                            ("ACO_VUL.2", "", False),
                                            ("ACO_VUL.3", "", False),
                                            ("ADV_ARC.1", "", False),
                                            ("ADV_FSP.2", "", False),
                                            ("ADV_FSP.3", "", False),
                                            ("ADV_FSP.4", "", False),
                                            ("ADV_FSP.5", "", False),
                                            ("ADV_FSP.6", "", False),
                                            ("ADV_IMP.1", "", False),
                                            ("ADV_IMP.2", "", False),
                                            ("ADV_INT.1", "", False),
#.........这里部分代码省略.........
开发者ID:1modm,项目名称:CCToolkit,代码行数:103,代码来源:CCToolkit.py

示例6: here

# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import checklist [as 别名]
#   d.add_persistent_args(["--backtitle", "My little program"])

# In pythondialog 3.x, you can compare the return code to d.OK, Dialog.OK or
# "ok" (same object). In pythondialog 2.x, you have to use d.DIALOG_OK, which
# is deprecated since version 3.0.0.
if d.yesno("Are you REALLY sure you want to see this?") == d.OK:
    d.msgbox("You have been warned...")

    # We could put non-empty items here (not only the tag for each entry)
    code, tags = d.checklist(
        "What sandwich toppings do you like?",
        choices=[
            ("Catsup", "", False),
            ("Mustard", "", False),
            ("Pesto", "", False),
            ("Mayonnaise", "", True),
            ("Horse radish", "", True),
            ("Sun-dried tomatoes", "", True),
        ],
        title="Do you prefer ham or spam?",
        backtitle="And now, for something " "completely different...",
    )
    if code == d.OK:
        # 'tags' now contains a list of the toppings chosen by the user
        pass
else:
    code, tag = d.menu(
        "OK, then you have two options:",
        choices=[("(1)", "Leave this fascinating example"), ("(2)", "Leave this fascinating example")],
    )
    if code == d.OK:
开发者ID:greising,项目名称:PythonLearn,代码行数:33,代码来源:dialogapp.py

示例7: __init__

# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import checklist [as 别名]

#.........这里部分代码省略.........
        elif tag == '(2)':
            self.commitsMenu()

        elif tag == '(3)':
            self.commitsMenu(revert = True)

        elif tag == '(4)':
            self.clearFilesAfterMerge()

        sys.stdout = __stdout


    def commitsMenu(self, revert = False):
        """
        Recent commits menu
        Allows selecting commits to build list of files and send from selected revisions

        :author: Damian Kęska <[email protected]>
        :return: None
        """

        commits = list()
        choices = []
        log = self._gitCommand('--no-pager log --oneline')
        i = 0

        for line in log.split("\n"):
            i = i + 1
            separator = line.find(' ')
            commits.append({'id': line[0:separator], 'title': line[(separator+1):], 'number': i})
            choices.append(("("+line[0:separator]+")", line[(separator+1):], 0))

        if revert:
            code, tag = self.dialog.checklist("Revert commits (total: "+str(len(commits))+")", choices=choices, width=120, height=20, list_height=10)
        else:
            code, tag = self.dialog.checklist("Submit commits (total: "+str(len(commits))+")", choices=choices, width=120, height=20, list_height=10)

        if tag:
            if revert:
                return self._appendCommitRevertFiles(commits, selected=tag)

            ## array of fileName => contents
            files = {}
            i = 0

            for commitID in tag:
                i = i + 1
                commitID = commitID.replace('(', '').replace(')', '')

                filesList = self._gitCommand('diff-tree --no-commit-id --name-only -r '+commitID)

                if "fatal:" in filesList:
                    self.kernel.logging.output('Cannot get list of files for revision '+commitID, 'git')
                    continue

                self._appendCommitFiles(commitID, filesList, files, commitNumber = i)


    def _appendCommitRevertFiles(self, commits, selected):
        """
        Append revert of commits

        :param commits: List of all avaliable commits
        :param selected: Selected commits
        :return:
        """
开发者ID:Panthera-Framework,项目名称:copysync,代码行数:70,代码来源:git.py


注:本文中的dialog.Dialog.checklist方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。