示例#1
0
def menu():

    #PYINQUIRER1
    """
    style = style_from_dict({
        Token.QuestionMark: '#E91E63 bold',
        Token.Selected: '#673AB7 bold',
        Token.Instruction: '',  # default
        Token.Answer: '#2196f3 bold',
        Token.Question: '',
    })
    """

    #PyInquirer2

    style = prompt_toolkit_style.from_dict({
        'separator': '#E91E63',
        'questionmark': '#E91E63',
        'focus': '#2196f3',
        'checked': '#2196f3',  # default
        'pointer': '#ff8700',  # AWS orange
        'instruction': '#ff8700',  # default
        'answer': '#00ffd7',  # AWS orange
        'question': '#2196f3',
    })

    questions = ConstruireQuestions()

    # PYINQUIRER1
    # answers = prompt(questions, style=style)

    #PyInquirer2
    answers = prompt.prompt(questions, style=style)

    return answers
示例#2
0
def encounter2b():
    prompt.prompt(
        {
            'type':
            'list',
            'name':
            'weapon',
            'message':
            'Pick one',
            'choices': [
                'Use the stick', 'Grab a large rock',
                'Try and make a run for it', 'Attack the wolf unarmed'
            ]
        },
        style=custom_style_2)
    print('The wolf mauls you. You die. The end.')
示例#3
0
def ask_direction():
    directions_prompt = {
        'type': 'list',
        'name': 'direction',
        'message': 'Which direction would you like to go?',
        'choices': ['Forward', 'Right', 'Left', 'Back']
    }
    answers = prompt.prompt(directions_prompt)
    return answers['direction']
示例#4
0
        'list',
        'name':
        'theme',
        'message':
        'What do you want to do?',
        'choices': [
            'Order a pizza', 'Make a reservation',
            Separator(), 'Ask for opening hours', {
                'name': 'Contact support',
                'disabled': 'Unavailable at this time'
            }, 'Talk to the receptionist'
        ]
    },
    {
        'type': 'list',
        'name': 'size',
        'message': 'What size do you need?',
        'choices': ['Jumbo', 'Large', 'Standard', 'Medium', 'Small', 'Micro'],
        'filter': lambda val: val.lower()
    },
    {
        'type': 'list',
        'name': 'delivery',
        'message': 'Which vehicle you want to use for delivery?',
        'choices': get_delivery_options,
    },
]

answers = prompt.prompt(questions, style=custom_style_2)
pprint(answers)
示例#5
0
def menu():
    """
    orange = '#F19066'
    pink = '#f78fb3'
    yellow = '#f5cd79'
    cyan = '#63CDDA'
    """

    style = Style.from_dict({
        'separator': '#E91E63',
        'questionmark': '#E91E63',
        'focus': '#2196f3',
        'checked': '#2196f3',  # default
        'pointer': '#ff8700',  # AWS orange
        'instruction': '#ff8700',  # default
        'answer': '#00ffd7',  # AWS orange
        'question': '#2196f3',
    })

    cartes_dispo = ListAvailableNetworkCards()
    cartes_dispo.sort()
    cartes_dispo.append('CANCEL')

    #  print(cartes_dispo)

    questions = [
        {
            'type':
            'list',
            'name':
            'app_choice',
            'message':
            'What do you want to do ?',
            'choices': [
                'Reboot Network Card', 'Change Network Card',
                'Choose a Network Card', 'Enable a Network Card',
                'Disable a Network Card', 'Change DNS', 'Quit'
            ]
        },

        # >>>> Adapter List <<<<

        # Redémarrer
        {
            'type': 'list',
            'name': 'adapter name',
            'message':
            'Pick the Network Card you want to reboot : (entrer CANCEL to quit)',
            'choices': cartes_dispo,
            #'default': cartes_dispo[1],
            'when':
            lambda answers: answers['app_choice'] == 'Reboot Network Card'
        },

        #
        {
            'type':
            'list',
            'name':
            'choose_adapter',
            'message':
            'Pick the Network Card you want to enable :',
            'choices':
            cartes_dispo,
            'when':
            lambda answers: answers['app_choice'] == 'Choose a Network Card'
        },

        # Changer
        {
            'type': 'list',
            'name': 'change_adapter_old',
            'message': 'pick the Network Card you want to disable : ',
            'choices': cartes_dispo,
            'when':
            lambda answers: answers['app_choice'] == 'Change Network Card'
        },
        {
            'type':
            'list',
            'name':
            'change_adapter_new',
            'message':
            'pick the Network Card you want to enable : ',
            'choices':
            cartes_dispo,
            'when':
            lambda answers: answers['app_choice'] == 'Change Network Card' and
            answers['change_adapter_old'] != 'CANCEL'
        },

        # Eteindre
        {
            'type':
            'list',
            'name':
            'adapter_off',
            'message':
            'pick the Network Card you want to disable : ',
            'choices':
            cartes_dispo,
            'when':
            lambda answers: answers['app_choice'] == 'Disable a Network Card'
        },

        # Allumer
        {
            'type':
            'list',
            'name':
            'adapter_on',
            'message':
            'pick the Network Card you want to enable',
            'choices':
            cartes_dispo,
            'when':
            lambda answers: answers['app_choice'] == 'Enable a Network Card'
        },

        # Change DNS
        {
            'type': 'list',
            'name': 'choose_dns_first',
            'message': 'Choisis la carte Réseau concernée :',
            'choices': cartes_dispo,
            'when': lambda answers: answers['app_choice'] == 'Change DNS'
        },
        {
            'type':
            'list',
            'name':
            'choose_dns_second',
            'message':
            'Choisis le DNS à appliquer : ',
            'choices': [DNS_list[k][0] for k in range(len(DNS_list))],
            'when':
            lambda answers: answers['app_choice'] == 'Change DNS' and answers[
                'choose_dns_first'] != 'CANCEL'
        },

        # >>>> Confirms <<<<
        {
            'type':
            'confirm',
            'name':
            'change_confirm',
            'message':
            'Are you sure you want to reboot it ?',
            'default':
            False,
            'when':
            lambda answers: answers['app_choice'] == 'Change Network Card' and
            answers['change_adapter_old'] != 'CANCEL' and answers[
                'change_adapter_new'] != 'CANCEL'
        },

        #{
        #    'type': 'confirm',
        #    'name': 'relancer_confirm',
        #    'message': 'souhaitez vous redémarrer la carte réseau ?',
        #    'default': False,
        #    'when': lambda answers: answers['app_choice'] == 'Reboot Network Card' and answers['adapter name'] != 'CANCEL'
        #},
        {
            'type': 'confirm',
            'name': 'quit_confirm',
            'message': 'Do you want to Exit ?',
            'default': False,
            'when': lambda answers: answers['app_choice'] == 'Quit'
        }
    ]

    answers = prompt.prompt(questions, style=style)

    return answers