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


Python Dialog.inputbox方法代码示例

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


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

示例1: input

# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import inputbox [as 别名]
    msg = "You chose the 'Help' button in the previous dialog."
else:
    msg = "Unexpected exit code from d.yesno(). Please report a bug."

# It is possible to explicitely specify the width and height of the widget
# instead of relying on 'autowidgetsize'.
d.msgbox(msg, width=50, height=7)


# *****************************************************************************
# *                            'inputbox' example                             *
# *****************************************************************************
code, user_input = d.inputbox("""\
The 'inputbox' widget can be used to read input (as a string) from the user. \
You can test it now:""",
                              init="Initial contents",
                              title="'inputbox' example",
                              help_button=True, extra_button=True,
                              extra_label="Cool button")

if code == d.OK:
    msg = "Your input in the previous dialog was '{0}'.".format(user_input)
elif code == d.CANCEL:
    msg = "You chose the 'Cancel' button in the previous dialog."
elif code == d.ESC:
    msg = "You pressed the Escape key in the previous dialog."
elif code == d.HELP:
    msg = "You chose the 'Help' button with input '{0}' in the previous " \
    "dialog.".format(user_input)
elif code == d.EXTRA:
    msg = 'You chose the Extra button ("Cool button") with input \'{0}\' ' \
开发者ID:skalkoto,项目名称:pythondialog,代码行数:33,代码来源:simple_example.py

示例2: WindowsInstallApp

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

#.........这里部分代码省略.........
    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
            if 'RO' not in dev or dev['RO'] == '1': continue
            devices.append(dev)

        self.d.msgbox('Detected Devices:\n\n' + '\n'.join(
            [' '.join([dev['NAME'], dev['SIZE']]) for dev in devices]))

        self.devices = devices

    def select_disk(self):
        self.detect_blockdevs()

        entries = [tuple([device['NAME'], '-']) for device in self.devices] + [('OTHER', '+')]
        code, tag = self.d.menu('Choose an installation drive', choices=entries)
        if code != self.d.OK: raise FailedInstallStep

        if tag == 'OTHER':
            code, tag = self.d.inputbox('Enter a path to a block device')
            if code != self.d.OK:
                raise FailedInstallStep

            if not os.path.isfile(tag):
                raise FailedInstallStep

            import stat
            mode = os.stat(tag).st_mode
            if not stat.S_ISBLK(mode):
                raise FailedInstallStep

        code, confirmation = self.d.inputbox('This will erase ALL data on %s' % tag + \
            '\n\nType \'YES\' to continue', width=40, height=15)
        if code != self.d.OK or confirmation != 'YES': raise FailedInstallStep

        self.install_drive = tag
        self.logger.info('Block device {} selected for installation'.format(self.install_drive))

    def supports_uefi(self):
        p = subprocess.Popen(['efivar', '-l'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        uefi = True if p.returncode == 0 else False
        return uefi

    def auto_prepare(self):
        try:
            self.select_disk()
        except FailedInstallStep:
            self.d.msgbox('Disk selection failed. Please retry the step to prepare the storage device.', width=40)
            raise

        for dir in [self.system_dir, self.boot_dir]:
            if mountpoint(dir): unmount(dir)
开发者ID:jakogut,项目名称:KiWI,代码行数:70,代码来源:install.py

示例3: setup_mixer

# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import inputbox [as 别名]
d.infobox("Setting up the audio mixer...")
setup_mixer()

if install_type == 'Base':
	complete()
		
#  Disable unused channels because we're going to be a repeater
#  Turn off AFOUT
set_alsa_mixer('Left Input Mixer IN1_L P', 'off')
set_alsa_mixer('Left Input Mixer CM1_L N', 'off')
#  Turn off AFIN
set_alsa_mixer('LOL Output Mixer L_DAC', 'off')

code = d.CANCEL
while code != d.OK:
	code, call = d.inputbox("Input the repeater's callsign", title = 'Repeater Callsign');
	if code == d.ESC or code == d.CANCEL:
		quit()
	call = call.upper()
	callre = re.compile('^[A-Z0-9]{1,3}[0-9]{1}[A-Z0-9]{0,3}[A-Z]{1}$')
	if not callre.match(call):
		code = d.CANCEL
		d.msgbox('The callsign you entered is invalid', title = 'Invalid Callsign');

code, module = d.radiolist("Repeater Module", title = 'Repeater Module', choices = [ ('A', 'Usually 23cm/1.2GHz', False), 
                                                                      ('B', 'Usually 70cm/440MHz', True),
                                                                      ('C', 'Usually 2m/144MHz', False),
                                                                      ('D', 'Testing Module', False) ])

dstarrepeater_settings['callsign'] = "{:7.7s}{:1.1s}".format(call, module)
dstarrepeater_settings['gateway'] =  "{:7.7s}G".format(call)                                   
开发者ID:johnhays,项目名称:udrc-tools,代码行数:33,代码来源:udrc-setup.py

示例4: Dialog

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

config = {}

locale.setlocale(locale.LC_ALL, '')

d = Dialog(dialog="dialog")
d.set_background_title("pizza-auth configuration wizard")

d.msgbox("Welcome to the configuration interface for pizza-auth.")

config["auth"] = {}

code, tag = d.menu("Are you running this for a corp or alliance?",
		choices = [("1.", "Corporation"),
			   ("2.", "Alliance")])
if code != d.OK:
	sys.exit()

if tag == "1.":
	mode = "corp"
	config["auth"]["corp"] = d.inputbox("What is your corporation's name?")
	config["auth"]["allianceshort"] = d.inputbox("What is your corporation's ticker?")

elif tag == "2.":
	mode = "alliance"
	config["auth"]["alliance"] = d.inputbox("What is your alliance's name?")
	config["auth"]["allianceshort"] = d.inputbox("What is your corporation's ticker?")


开发者ID:xxpizzaxx,项目名称:pizza-auth,代码行数:30,代码来源:wizard.py

示例5: float

# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import inputbox [as 别名]
                    z = float(answers[1][2])
                    pos = Position(x, y, z)
                    q = chargeUnit.multiplier()  # how much charge do you use?
                    par = (Particle(Position(x, y, z), q))
                    force = par.get_force()  # here's the error
                    d.msgbox(force.text())
                    del par  # keep memory usage low. Might be important for large projects/complex objects.
                    break
                except:
                    d.msgbox("All inputs must be numbers only.")

        elif tag == "Save":
            code, path = d.dselect("/", title="Choose a directory to save your file in:")
            if code != d.OK:
                break
            code, file = d.inputbox("Enter a file name:")
            if code != d.OK:
                break
            try:
                output_file = open(path+file, "w")
            except:
                print("Cannot open file.")
                break
            string = "<conditions>\n"
            for obj in objects:
                string += "    <particle>"
                string += "        <position>["+str(obj.position.x)+","+str(obj.position.y)+","+str(obj.position.z)+\
                          "]</position>"
                string += "        <charge>"+str(obj.charge)+"</charge>"
                string += "    </particle>"
            string += "</conditions>"
开发者ID:idajourney,项目名称:PhysTools,代码行数:33,代码来源:main.py

示例6: get_info_via_dialog

# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import inputbox [as 别名]
def get_info_via_dialog():
    global server
    global username
    global password
    global user  # chmod user
    global cred_file
    global mount_folder
    global create_mount_fld_as_sharename
    global fstab_loc

    from dialog import Dialog
    d = Dialog(dialog="dialog")

    button_names = {d.OK: "OK",
                    d.CANCEL: "Cancel",
                    d.HELP: "Help",
                    d.EXTRA: "Extra"}


    code, tag = d.mixedform("What sandwich toppings do you like?",
                             [("Server", 1, 1, "",1, 10, 20, 20, 0),
                              ("Username", 2, 1, "",2, 10, 20, 20, 0),
                              ("Password", 3, 1, "", 3, 10, 20, 20, 1)
                              ]
                )
    import pprint
    pprint.pprint(code)
    pprint.pprint(tag[1])

    if tag[0] != '' and tag[1] != '' and tag[2] != '':
        server = tag[0]
        username = tag[1]
        password = tag[2]
    else:
        sys.exit("Please specify all the input box's")

    code, tag = d.inputbox("Please enter the username who will have R/W access to the mounts")

    pprint.pprint(code)
    pprint.pprint(tag)

    #need to add checks for user
    user = tag

    code, tag = d.inputbox("Please enter the filename only, it will be edited to add the username and password\n and will be user in fstab or mount cmd")
    if tag != '':
        cred_file = tag


    code, tag = d.fselect('/etc/fstab')
    if tag != '':
        fstab_loc = tag

    import pathlib

    code, tag = d.dselect('/media')
    if tag != '' and pathlib.Path(tag).is_dir():
        mount_folder = tag
    else:
        sys.exit("Please select a folder to mount!")

    pprint.pprint(code)
    pprint.pprint(tag)
开发者ID:vivekdave,项目名称:autoCifs,代码行数:65,代码来源:index.py

示例7: MainDialog

# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import inputbox [as 别名]
class MainDialog():
    def __init__(self, auto_run=True):
        self.d = Dialog(dialog="dialog", autowidgetsize=True, DIALOGRC='rc')
        self.d.set_background_title("ATILLA - Transition shell")
        if auto_run:
            self.run()

    def check_address(self, address):
        ip_regex = re.compile("^192.168.(10|253).\d{1,3}$")
        address_regex = re.compile("^([a-zA-Z0-9-]*\.){0,4}atilla\.org$")
        return ip_regex.match(address) or address_regex.match(address)

    def check_user(self, user):
        user_regex = re.compile("^[a-zA-Z0-9-]{0,255}$")
        return user_regex.match(user)

    def input_ssh_hostname(self):
        while True:
            code, address = self.d.inputbox("Enter the server FQDN / IP : ",
                                            width=35)

            if code == self.d.OK:
                if self.check_address(address):
                    return address
                else:
                    self.d.msgbox("Invalid address, plase make sure that you"
                                  " are trying to reach an ATILLA server",
                                  width=50, height=10)
            else:
                return None

    def input_ssh_user(self):
        while True:
            code, user = self.d.inputbox("Enter the username : ",
                                         init="root")
            if code == self.d.OK:
                if self.check_user(user):
                    return user
                else:
                    self.d.msgbox("Invalid user name")
            else:
                return None

    def ssh(self):
        hostname = self.input_ssh_hostname()
        if hostname is not None:
            user = self.input_ssh_user()
            if user is not None:
                os.system('clear')
                os.system('ssh ' + user + '@' + hostname)

    def learn_more(self):
        text = ("This application is meant to provide a user-friendly "
                "interface for SSH bouncing into ATILLA network.\n\n"
                "Source code available at :\n"
                "https://gitlab.atilla.org/adminsys/transition-shell")
        self.d.msgbox(text)

    def main_menu(self):
        main_menu_choices = [("#1", "Connect to another SSH server"),
                             ("#2", "Learn more about this application"),
                             ("#3", "Quit the program")]
        while True:
            code, tag = self.d.menu(("Welcome to ATILLA transition server, "
                                     "please choose one of the following "
                                     "options :"),
                                    choices=main_menu_choices)
            if code == self.d.OK:
                if tag == "#1":
                    self.ssh()
                elif tag == "#2":
                    self.learn_more()
                elif tag == "#3":
                    return
            else:
                return

    def run(self):
        self.main_menu()
        self.d.infobox("Goodbye !")
        time.sleep(0.25)
        os.system('clear')
开发者ID:Atilla-Admin,项目名称:transititon-shell,代码行数:84,代码来源:transition-shell.py

示例8: main

# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import inputbox [as 别名]
def main():
    locale.setlocale(locale.LC_ALL, '')
    d = Dialog(dialog="dialog", autowidgetsize=True)
    d.set_background_title("Programme de support express")
    d.msgbox("Bienvenue sur le programme de support technique. Celui-ci vous guidera pour résoudre votre probleme ou la soumettre de maniere correcte !")
    code, programme = d.menu("Quel est le programme concerné par le probleme ?:",
                       choices=[("serveur", "Mon serveur en entier, le soucis est global, ou n'est pas lié à un programme particulier."),
                                ("web", "Mon site web (apache2, nginx, ioncube...)"),
                                ("minecraft", "Un serveur de jeu Minecraft"),
                                ("source", "Un serveur de jeu CS:GO, TF2, ou autre jeu source"),
                                ("vpn", "Un VPN OpenVpn"),
                                ("ssh", "Le SSHd (connexion au serveur avec PuTTy ou équivalent)"),
                                ("bdd", "Une base de données (MySql, phpmyadmin...)"),
                                ("autre", "Autre chose, qui n'est pas expliqué ici")
                                ])

    if code == d.OK:
        if d.yesno("Le principal, avez vous lu les logs de l'application ou du service ?", yes_label="Bien sur que oui !", no_label="Euh... On peut le faire maintenent ?") == d.OK:
            if d.yesno("Et vous n'avez rien trouvé dedans?", yes_label="Sisi, j'ai vu des erreurs", no_label="Vraiment rien trouvé!") == d.OK:
                if programme == "minecraft":
                    if d.yesno("Hum... S'agit t'il d'un trés long message avec des at à quasiment chaque ligne ?", yes_label="Oui, c'est ca !", no_label="Non !") == d.OK:
                        d.msgbox("C'est une stacktrace. Il doit y avoir le nom d'un ou plusieurs plugins dedans, ainsi que leur version. Essaye de les mettre à jour.")
                        if d.yesno("La mise à jour et le redémarrage ont-ils résolu le probleme ?", yes_label="Oui, merci !", no_label="Non :'(") == d.OK:
                            d.msgbox("Dans, ce cas, merci à toi ! :)")
                            sys.exit(0)
                        else:
                            propositionsMessages(d, programme)
                    else:
                        d.msgbox("Pas grave, nous allons trouver, alors dit moi :")

                code, tag = d.menu("Quel genre de messages ?:",
                                   choices=[("1", "Des messages d'erreurs"),
                                            ("2", "Des \"Warnings\""),
                                            ("3", "Des messsages que j'ai pas trop compris")
                                            ])
                tag = int(tag)
                if code == d.OK:
                    if tag == 1:
                        d.msgbox("Super ! La plupart du boulot est fait ! Essayez d'entrer dans google le message d'erreur en retirant la date, l'heure, les chemins de fichiers et tout autre signe distinctif, puis appliquez les solutions proposées")
                        if d.yesno("Cela à résolu votre probleme ?", yes_label="Oui, merci beaucoup !", no_label="Malheureusement non !") == d.OK:
                            d.msgbox("Dans, ce cas, merci à toi ! :)")
                            sys.exit(0)
                        else:
                            propositionsMessages(d, programme)
                    elif tag == 2:
                        if d.yesno("Le mieux serait d'entrer ces messages sans trop de signes distinctifs dans google et d'essayer les solutions proposées. Est-ce que cela résout le problème ?", yes_label="Oui, merci beaucoup !", no_label="Malheureusement non !") == d.OK:
                            d.msgbox("Dans, ce cas, merci à toi ! :)")
                            sys.exit(0)
                        else:
                            propositionsMessages(d, programme)
                    elif tag == 3:
                        d.msgbox("Essayez d'entrer dans google le message en retirant la date, l'heure, les chemins de fichiers et tout autre signe distinctif, puis appliquez les solutions proposées")
                        if d.yesno("Cela à résolu votre probleme ?", yes_label="Oui, merci beaucoup !", no_label="Malheureusement non !") == d.OK:
                            d.msgbox("Dans, ce cas, merci à toi ! :)")
                            sys.exit(0)
                        else:
                            propositionsMessages(d, programme)
            else:
                d.msgbox("Si tu ne trouves pas de message particulier, cherche si l'application n'a pas d'autres fichiers de logs. Si ce n'est pas le cas, passe nous voir au support sur IRC")
        else:
            d.msgbox("Pas de soucis, regardons. Tu dois chercher des lignes contenant des erreurs")
            if d.yesno("Connais-tu le chemin vers ces logs ? Je ne connais que ceux par défault, et si tes serveurs sont installés a d'autres endroits, je ne les trouverai pas.", yes_label="Oui, je connais!", no_label="Malheureusement non !") != d.OK:
                d.msgbox("Voici les logs, si je les trouves...")
                try:
                    if programme == "serveur":
                        d.textbox("/var/log/syslog")
                    elif programme == "web":
                        d.textbox("/var/log/apache2/error.log")
                    elif programme == "minecraft":
                        code, serv = d.inputbox("Quel est le nom du serveur aprés /home/minecraft ? (tapez juste / si il n'y en a pas)", init="/")
                        d.textbox("/home/minecraft/" + serv + "/logs/latest.log")
                    elif programme == "source":
                        d.msgbox("Les logs pour les serveurs source sont dans la console seulement")
                    elif programme == "vpn":
                        d.textbox("/var/log/syslog") # oui, ca log dans syslog openvpn :o
                    elif programme == "sshd":
                        d.textbox("/var/log/auth.log")
                        d.textbox("/var/log/messages")
                    elif programme == "bdd":
                        d.textbox("/var/log/mysql.log")
                    else:
                        d.msgbox("Le mieux serait de chercher ce chemin sur google...")
                        code, logs = d.inputbox("Quel est ce chemin ?", init="/var/log/[...]")
                        if code == d.OK:
                            d.textbox(logs)
                        else:
                            d.msgbox("Au revoir è_é!")
                            sys.exit(2)
                except DialogError:
                    d.msgbox("Je n'ai pas trouvé le fichier :'(. Le mieux serait de chercher ce chemin sur google...")
                    code, logs = d.inputbox("Quel est ce chemin ?", init="/var/log/[...]")
                    if code == d.OK:
                        d.textbox(logs)
                    else:
                        d.msgbox("Au revoir è_é!")
                        sys.exit(2)
            else:
                code, logs = d.inputbox("Quel est ce chemin ?", init="/var/log/[...]")
                if code == d.OK:
                    d.textbox(logs)
#.........这里部分代码省略.........
开发者ID:paris-ci,项目名称:support,代码行数:103,代码来源:support.py

示例9: print

# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import inputbox [as 别名]
    if action == "Connect to a VM/CT":
        with shelve.open('pvcdb') as db:
            data = db['vmctlist']
            print(data)
            sys.exit()
    elif action == "Get VM/CT list":
        pass
    elif action == "Configure Tool":
        data = pickle.load(open("data.p", "rb"))
        code, action = d.menu("Configure Tool",
            choices=[("Set IP of Proxmox server", ""),
                ("Set username of Proxmox user to login as", ""),
                ("Set password of Proxmox user to log in as", "")])
        if action == "Set IP of Proxmox server":
            code, ip = d.inputbox("Enter IP of Proxmox server:", init=data[1])
        elif action == "Set username of Proxmox user to login as":
            code, username = d.inputbox("Enter username of SSH user:")
        elif action == "Set password of Proxmox user to login as":
            code, password = d.inputbox("Enter password of SSH user:")
        else:
            d.msgbox("Oops. Something went wrong...")

    elif action == "Exit Tool":
        sys.exit()


    elif action == "":
        if d.yesno("Are you REALLY sure you want to exit?") == d.OK:
            sys.exit()
开发者ID:jelimoore,项目名称:pve-virtual-console,代码行数:31,代码来源:program.py


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