示例#1
0
    def requireSelect(self, options):
        print('-' * 70)
        select_name = options['name']
        select_data = options['data']
        Message.ShowSelect('请选择%s, 可选值为 [0~%d], 分别代表:' %
                           (select_name, len(select_data) - 1))
        print('')
        for select in select_data:
            Message.ShowMenu('%s' % select['desc'])
        print('')
        Message.ShowSelect('请选择%s [0~%d]:' %
                           (select_name, len(select_data) - 1),
                           end="")
        user_select = input()

        if not user_select or not user_select.isnumeric():
            Message.ShowError('您输入了无效的地图标记类型, 程序终止')
            print('-' * 70)
            Common.exitWithPause(-1)

        user_select = int(user_select)

        if user_select < 0 or user_select >= len(select_data):
            Message.ShowError('您输入了无效的地图标记类型, 程序终止')
            print('-' * 70)
            Common.exitWithPause(-1)

        print('')
        Message.ShowInfo('您选择的是: %s' % select_data[user_select]['name'])
        print('-' * 70)
        print('\n')
        return user_select
示例#2
0
    def requireSelect(self, options):
        print('-' * 70)
        prompt = options['prompt']
        option_name = options['option_name']
        select_data = options['data']
        Message.ShowSelect('请选择%s, 可选值为 [0~%d], 分别代表:' %
                           (prompt, len(select_data) - 1))
        print('')
        for select in select_data:
            Message.ShowMenu('%s' % select['desc'])
        print('')
        Message.ShowSelect('请选择%s [0~%d]:' % (prompt, len(select_data) - 1),
                           end="")
        user_select = input()

        if not user_select or not user_select.isnumeric():
            Message.ShowError(
                '您选择了无效的%s, 程序终止' %
                (option_name if option_name is not None else '选项'))
            print('-' * 70)
            Common.exit_with_pause(-1)

        user_select = int(user_select)

        if user_select < 0 or user_select >= len(select_data):
            Message.ShowError(
                '您选择了无效的%s, 程序终止' %
                (option_name if option_name is not None else '选项'))
            print('-' * 70)
            Common.exit_with_pause(-1)

        print('')
        Message.ShowInfo('您选择的是: %s' % select_data[user_select]['name'])
        print('-' * 70)
        print('')
        return user_select