本文整理汇总了Python中dialog.Dialog.infobox方法的典型用法代码示例。如果您正苦于以下问题:Python Dialog.infobox方法的具体用法?Python Dialog.infobox怎么用?Python Dialog.infobox使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dialog.Dialog
的用法示例。
在下文中一共展示了Dialog.infobox方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Command
# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import infobox [as 别名]
class Command(BaseCommand):
help = "Import subjects from xls file"
args = 'filename'
def handle(self, *args, **options):
source_filename = args[0]
doc = xlrd.open_workbook(source_filename, formatting_info=True)
format_doc = SubjectFormat(doc)
from dialog import Dialog
self.dialog = Dialog()
if format_doc.sheet.ncols >= len(format_doc.cells):
logic = SubjectImportLogic(format_doc)
total = logic.doc.sheet.nrows - logic.doc.start_line
index = 0
self.dialog.gauge_start()
for index, parsed_row in enumerate(logic.doc):
logic.process_row(index, parsed_row)
try:
text=(u'Импорт: %s' % parsed_row[0][0]).encode('utf-8')
except IndexError:
text = (u'Ошибка').encode('utf-8')
self.dialog.gauge_update(int(float(index)/total*100),
text=text,
update_text=True)
self.dialog.gauge_stop()
num_errors = len(logic.errors)
self.dialog.infobox(u'Ошибок %d из %d: ' % (num_errors, total))
示例2: __init__
# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import infobox [as 别名]
class UI:
def __init__(self):
from dialog import Dialog
self.d = Dialog()
self.w=0
self.h=0
def message(self, text, title=None):
self.d.infobox( text )
def menu(self, title, subtitle, choices):
return self.d.menu( subtitle, title=title, choices=choices, width=self.w, height=self.h)[1]
def confirm(self, title, question):
return self.d.yesno(question, title=title, width=50, height=5)
示例3: Command
# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import infobox [as 别名]
class Command(BaseCommand):
help = "Import data from xls file"
args = 'filename'
def handle(self, *args, **options):
source_filename = args[0]
source_file = open(source_filename, 'r')
descriptor, name = tempfile.mkstemp()
os.fdopen(descriptor, 'wb').write(source_file.read())
doc = xlrd.open_workbook(name, formatting_info=True)
format_doc = ListenerFileFormat(doc)
from dialog import Dialog
self.dialog = Dialog()
if format_doc.sheet.ncols >= len(format_doc.cells):
logic = ListenerImportLogic(format_doc)
total = logic.doc.sheet.nrows - logic.doc.start_line
self.dialog.gauge_start()
for index, parsed_row in enumerate(logic.doc):
logic.process_row(index, parsed_row)
try:
text=(u'Импорт: %s' % ' '.join(parsed_row[5])).encode('utf-8')
except IndexError:
text = (u'Ошибка').encode('utf-8')
self.dialog.gauge_update(int(float(index)/total*100),
text=text,
update_text=True)
self.dialog.gauge_stop()
num_errors = len(logic.errors)
self.dialog.infobox(u'Ошибок %d из %d: ' % (num_errors, total))
next_cmd = NormalizeCommand()
next_cmd.handle()
示例4: WindowsInstallApp
# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import infobox [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
#.........这里部分代码省略.........
示例5: Dialog
# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import infobox [as 别名]
kontrol.remove(kont)
for kont in kontrol:
os.system(kur+kont)
from dialog import Dialog
import yaml
d = Dialog(dialog="dialog")
f = open("/tmp/kurulum.log","w")
_kurulum_dosya="/root/ayarlar/kurulum.yml"
kurulum_dosya=""
if not os.path.exists(_kurulum_dosya):
d.infobox(text=_kurulum_dosya+" bulunamadı!")
sys.exit()
else:
os.system("cp "+_kurulum_dosya+" /opt/kurulum.yml")
kurulum_dosya="/opt/kurulum.yml"
def komutCalistir(c):
out = subprocess.check_output(c,stderr=subprocess.STDOUT,shell=True,universal_newlines=True)
return out.replace("\b","") #byte-string çevrim
def kurulum_oku(kurulumdos):
with open(kurulumdos, 'r') as f:
param = yaml.load(f)
return param
def kurulum_yaz(param,kurulumdos):
示例6: quit
# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import infobox [as 别名]
Select a type of install. You may choose to install the OpenDV components \
(ircDDBGateway and DStarRepeater) to implement a D-STAR repeater, or to just do the \
basic setup for the UDRC.
"""
d.msgbox(welcome_text, title='Welcome!', height=20, width=60)
code, install_type = d.menu(menu_text,
title='Install Type',
choices = [ ('Full', 'DStarRepeater & ircDDBGateway'),
('RepeaterOnly', 'DStarRepeater only'),
('Base', 'Base configuration only') ]);
if code == d.ESC or code == d.CANCEL:
quit()
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');
示例7: MainApp
# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import infobox [as 别名]
class MainApp(object):
"""
Main App class
"""
def __init__(self):
self.dialog = Dialog(autowidgetsize=True)
self.dialog.set_background_title(
'Python vSphere Client version {}'.format(__version__)
)
self.agent = None
def about(self):
welcome = (
'Welcome to the Python vSphere Client version {}.\n\n'
'PVC is hosted on Github. Please contribute by reporting '
'issues, suggesting features and sending patches using '
'pull requests.\n\n'
'https://github.com/dnaeon/pvc'
)
self.dialog.msgbox(
title='Welcome',
text=welcome.format(__version__)
)
def login(self):
"""
Login to the VMware vSphere host
Returns:
True on successful connect, False otherwise
"""
form_text = (
'Enter IP address or DNS name '
'of the VMware vSphere host you wish '
'to connect to.\n'
)
elements = [
pvc.widget.form.FormElement(label='Hostname'),
pvc.widget.form.FormElement(label='Username'),
pvc.widget.form.FormElement(label='Password', attributes=0x1),
]
form = pvc.widget.form.Form(
dialog=self.dialog,
form_elements=elements,
mixed_form=True,
title='Login Details',
text=form_text,
)
while True:
code, fields = form.display()
if code in (self.dialog.CANCEL, self.dialog.ESC):
return False
if not all(fields.values()):
self.dialog.msgbox(
title='Error',
text='Invalid login details, please try again.\n'
)
continue
self.dialog.infobox(
title='Establishing Connection',
text='Connecting to {} ...'.format(fields['Hostname']),
)
self.agent = VConnector(
host=fields['Hostname'],
user=fields['Username'],
pwd=fields['Password'],
)
try:
self.agent.connect()
text = '{} - {} - Python vSphere Client version {}'
background_title = text.format(
self.agent.host,
self.agent.si.content.about.fullName,
__version__
)
self.dialog.set_background_title(background_title)
return True
except Exception as e:
self.dialog.msgbox(
title='Login failed',
text='Failed to login to {}\n\n{}\n'.format(self.agent.host, e.msg)
)
def run(self):
self.about()
if not self.login():
return
home = pvc.widget.home.HomeWidget(
agent=self.agent,
#.........这里部分代码省略.........
示例8:
# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import infobox [as 别名]
# check if selected_iface is already listed or not in interfaces file using debinterfaces
configured_iface = None
for adapter in interfaces.adapters:
item = adapter.export()
if item['name'] == selected_iface:
configured_iface = item
break
# remove from adapter list if it is already configured
if configured_iface is not None:
interfaces.removeAdapterByName(selected_iface)
code, tag = d.menu(Constants.TXT_SELECT_SOURCE, choices=[(Constants.DHCP, 'Dynamic IP'), (Constants.STATIC, 'Static IP')])
if code == Dialog.OK:
if tag == Constants.DHCP:
code = d.infobox(Constants.TXT_MESSAGE_DHCP)
# simply add
interfaces.addAdapter({
'name': selected_iface,
'auto': True,
'addrFam': 'inet',
'source': Constants.DHCP}, 0)
write_and_display_results(interfaces, selected_iface)
if tag == Constants.STATIC:
while True:
try:
code, values = d.form(Constants.TXT_CONFIG_STATIC_TITLE, [
# title, row_1, column_1, field, row_1, column_20, field_length, input_length
示例9: DialogCommunicator
# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import infobox [as 别名]
class DialogCommunicator(QuietCommunicator):
def __init__(self):
# some constant definitions to avoid using magic numbers
# for the DialogCommunicator mixedgauge dialog
self.WAIT = 7
self.DONE = 0
self.FAIL = 1
self.d = Dialog(dialog="dialog")
self.d.set_background_title("kotnetcli")
self.netlogin = self.WAIT
self.kuleuven = self.WAIT
self.invoeren = self.WAIT
self.opsturen = self.WAIT
self.download = self.WAIT
self.upload = self.WAIT
self.overal = 0
self.update()
def update(self):
self.d.mixedgauge("",
title="kotnetcli",
percent= self.overal,
elements= [ ("Netlogin openen", self.netlogin),
("KU Leuven kiezen", self.kuleuven),
("Gegevens invoeren", self.invoeren),
("Gegevens opsturen", self.opsturen),
("", ""),
("Download", self.download),
("Upload", self.upload)
])
def eventPingFailure(self):
self.d.infobox("Niet verbonden met het KU Leuven-netwerk.", 5, 30)
def eventPingAlreadyOnline(self):
self.d.infobox("U bent al online.", 5, 30)
def eventNetloginSuccess(self):
self.netlogin = self.DONE
self.overal = 40
self.update()
def eventNetloginFailure(self):
self.netlogin = self.FAIL
self.overal = 40
self.update()
def eventKuleuvenSuccess(self):
self.kuleuven = self.DONE
self.overal = 60
self.update()
def eventKuleuvenFailure(self):
self.kuleuven = self.FAIL
self.overal = 60
self.update()
def eventInvoerenSuccess(self):
self.invoeren = self.DONE
self.overal = 80
self.update()
def eventInvoerenFailure(self):
self.invoeren = self.FAIL
self.overal = 80
self.update()
def eventOpsturenSuccess(self):
self.opsturen = self.DONE
self.overal = 100
self.update()
def eventOpsturenFailure(self):
self.opsturen = self.FAIL
self.overal = 100
self.update()
def eventTegoedenBekend(self, downloadpercentage, uploadpercentage):
self.download = -downloadpercentage
self.upload = -uploadpercentage
self.overal = 100
self.update()
def beeindig_sessie(self, error_code=0):
print "" # print newline to clean prompt under dialog
示例10: MainDialog
# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import infobox [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')
示例11: Dialog
# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import infobox [as 别名]
# from libqtile import layout
locale.setlocale(locale.LC_ALL, '')
d = Dialog(autowidgetsize=True)
# should we start from empty or load some config
default_config = d.yesno("""This is Qtile setup program to prepair config to use Qtile.
Would you like to start from default config or load earlier config?""",
yes_label='Default',
no_label='Load file'
)
if default_config == 'ok':
d.infobox('Config is loading...')
config = confreader.File()
else:
home = expanduser("~")
code, config_file = d.fselect(home)
if code == 'ok':
config = confreader.File(config_file)
d.infobox('Config is loading...')
else:
d.infobox('File has not been loaded. Start gain :)')
print(config.__dict__)
示例12: Dialog
# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import infobox [as 别名]
locale.setlocale(locale.LC_ALL, '')
d = Dialog(dialog="dialog")
button_names = {d.OK: "OK",
d.CANCEL: "Cancel",
d.HELP: "Help",
d.EXTRA: "Extra"}
code, tag = d.menu("Some text that will be displayed above the menu entries",
choices=[("Tag 1", "Item text 1"),
("Tag 2", "Item text 2"),
("Tag 3", "Item text 3")])
if code == d.ESC:
d.msgbox("You got out of the menu by pressing the Escape key.")
else:
text = "You got out of the menu by choosing the {} button".format(
button_names[code])
if code != d.CANCEL:
text += ", and the highlighted entry at that time had tag {!r}".format(
tag)
d.msgbox(text + ".", width=40, height=10)
d.infobox("Bye bye...", width=0, height=0, title="This is the end")
time.sleep(2)
sys.exit(0)