本文整理汇总了Python中simpleline.render.containers.ListColumnContainer类的典型用法代码示例。如果您正苦于以下问题:Python ListColumnContainer类的具体用法?Python ListColumnContainer怎么用?Python ListColumnContainer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ListColumnContainer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PartitionSchemeSpoke
class PartitionSchemeSpoke(NormalTUISpoke):
""" Spoke to select what partitioning scheme to use on disk(s). """
category = SystemCategory
def __init__(self, data, storage, payload):
super().__init__(data, storage, payload)
self.title = N_("Partition Scheme Options")
self._container = None
self.part_schemes = OrderedDict()
self._auto_part_proxy = STORAGE.get_proxy(AUTO_PARTITIONING)
pre_select = self._auto_part_proxy.Type
supported_choices = get_supported_autopart_choices()
if supported_choices:
# Fallback value (eg when default is not supported)
self._selected_scheme_value = supported_choices[0][1]
for item in supported_choices:
self.part_schemes[item[0]] = item[1]
if item[1] == pre_select:
self._selected_scheme_value = item[1]
@property
def indirect(self):
return True
def refresh(self, args=None):
super().refresh(args)
self._container = ListColumnContainer(1)
for scheme, value in self.part_schemes.items():
box = CheckboxWidget(title=_(scheme), completed=(value == self._selected_scheme_value))
self._container.add(box, self._set_part_scheme_callback, value)
self.window.add_with_separator(self._container)
message = _("Select a partition scheme configuration.")
self.window.add_with_separator(TextWidget(message))
def _set_part_scheme_callback(self, data):
self._selected_scheme_value = data
def input(self, args, key):
""" Grab the choice and update things. """
if not self._container.process_user_input(key):
# TRANSLATORS: 'c' to continue
if key.lower() == C_('TUI|Spoke Navigation', 'c'):
self.apply()
return InputState.PROCESSED_AND_CLOSE
else:
return super().input(args, key)
return InputState.PROCESSED_AND_REDRAW
def apply(self):
""" Apply our selections. """
self._auto_part_proxy.SetType(self._selected_scheme_value)
示例2: NTPServersSpoke
class NTPServersSpoke(NormalTUISpoke):
category = LocalizationCategory
def __init__(self, data, storage, payload, time_spoke):
super().__init__(data, storage, payload)
self.title = N_("NTP configuration")
self._container = None
self._time_spoke = time_spoke
@property
def indirect(self):
return True
def _summary_text(self):
"""Return summary of NTP configuration."""
msg = _("NTP servers:")
if self._time_spoke.ntp_servers:
for status in format_ntp_status_list(self._time_spoke.ntp_servers):
msg += "\n%s" % status
else:
msg += _("no NTP servers have been configured")
return msg
def refresh(self, args=None):
super().refresh(args)
summary = self._summary_text()
self.window.add_with_separator(TextWidget(summary))
self._container = ListColumnContainer(1, columns_width=78, spacing=1)
self._container.add(TextWidget(_("Add NTP server")), self._add_ntp_server)
# only add the remove option when we can remove something
if self._time_spoke.ntp_servers:
self._container.add(TextWidget(_("Remove NTP server")), self._remove_ntp_server)
self.window.add_with_separator(self._container)
def _add_ntp_server(self, data):
new_spoke = AddNTPServerSpoke(self.data, self.storage, self.payload, self._time_spoke)
ScreenHandler.push_screen_modal(new_spoke)
self.redraw()
def _remove_ntp_server(self, data):
new_spoke = RemoveNTPServerSpoke(self.data, self.storage, self.payload, self._time_spoke)
ScreenHandler.push_screen_modal(new_spoke)
self.redraw()
def input(self, args, key):
if self._container.process_user_input(key):
return InputState.PROCESSED
else:
return super().input(args, key)
def apply(self):
pass
示例3: RootSelectionSpoke
class RootSelectionSpoke(NormalTUISpoke):
"""UI for selection of installed system root to be mounted."""
def __init__(self, roots):
super().__init__(data=None, storage=None, payload=None)
self.title = N_("Root Selection")
self._roots = roots
self._selection = roots[0]
self._container = None
@property
def selection(self):
"""The selected root fs to mount."""
return self._selection
@property
def indirect(self):
return True
def refresh(self, args=None):
super().refresh(args)
self._container = ListColumnContainer(1)
for root in self._roots:
box = CheckboxWidget(
title="{} on {}".format(root.name, root.device.path),
completed=(self._selection == root)
)
self._container.add(box, self._select_root, root)
message = _("The following installations were discovered on your system.")
self.window.add_with_separator(TextWidget(message))
self.window.add_with_separator(self._container)
def _select_root(self, root):
self._selection = root
def prompt(self, args=None):
""" Override the default TUI prompt."""
prompt = Prompt()
prompt.add_continue_option()
return prompt
def input(self, args, key):
"""Override any input so we can launch rescue mode."""
if self._container.process_user_input(key):
return InputState.PROCESSED_AND_REDRAW
elif key == Prompt.CONTINUE:
return InputState.PROCESSED_AND_CLOSE
else:
return key
def apply(self):
"""Define the abstract method."""
pass
示例4: SpecifyRepoSpoke
class SpecifyRepoSpoke(NormalTUISpoke, SourceSwitchHandler):
""" Specify the repo URL here if closest mirror not selected. """
category = SoftwareCategory
HTTP = 1
HTTPS = 2
FTP = 3
def __init__(self, data, storage, payload, instclass, protocol):
NormalTUISpoke.__init__(self, data, storage, payload, instclass)
SourceSwitchHandler.__init__(self)
self.title = N_("Specify Repo Options")
self.protocol = protocol
self._container = None
self._url = self.data.url.url
def refresh(self, args=None):
""" Refresh window. """
NormalTUISpoke.refresh(self, args)
self._container = ListColumnContainer(1)
dialog = Dialog(_("Repo URL"))
self._container.add(EntryWidget(dialog.title, self._url), self._set_repo_url, dialog)
self.window.add_with_separator(self._container)
def _set_repo_url(self, dialog):
self._url = dialog.run()
def input(self, args, key):
if self._container.process_user_input(key):
self.apply()
return InputState.PROCESSED_AND_REDRAW
else:
return NormalTUISpoke.input(self, args, key)
@property
def indirect(self):
return True
def apply(self):
""" Apply all of our changes. """
if self.protocol == SpecifyRepoSpoke.HTTP and not self._url.startswith("http://"):
url = "http://" + self._url
elif self.protocol == SpecifyRepoSpoke.HTTPS and not self._url.startswith("https://"):
url = "https://" + self._url
elif self.protocol == SpecifyRepoSpoke.FTP and not self._url.startswith("ftp://"):
url = "ftp://" + self._url
else:
# protocol either unknown or entry already starts with a protocol
# specification
url = self._url
self.set_source_url(url)
示例5: PartitionSchemeSpoke
class PartitionSchemeSpoke(NormalTUISpoke):
""" Spoke to select what partitioning scheme to use on disk(s). """
category = SystemCategory
def __init__(self, data, storage, payload, instclass):
NormalTUISpoke.__init__(self, data, storage, payload, instclass)
self.title = N_("Partition Scheme Options")
self._container = None
self.part_schemes = OrderedDict()
pre_select = self.data.autopart.type or DEFAULT_AUTOPART_TYPE
for item in AUTOPART_CHOICES:
self.part_schemes[item[0]] = item[1]
if item[1] == pre_select:
self._selected_scheme_value = item[1]
@property
def indirect(self):
return True
def refresh(self, args=None):
NormalTUISpoke.refresh(self, args)
self._container = ListColumnContainer(1)
for scheme, value in self.part_schemes.items():
box = CheckboxWidget(title=_(scheme), completed=(value == self._selected_scheme_value))
self._container.add(box, self._set_part_scheme_callback, value)
self.window.add_with_separator(self._container)
message = _("Select a partition scheme configuration.")
self.window.add_with_separator(TextWidget(message))
def _set_part_scheme_callback(self, data):
self._selected_scheme_value = data
def input(self, args, key):
""" Grab the choice and update things. """
if not self._container.process_user_input(key):
# TRANSLATORS: 'c' to continue
if key.lower() == C_('TUI|Spoke Navigation', 'c'):
self.apply()
self.close()
return InputState.PROCESSED
else:
return super(PartitionSchemeSpoke, self).input(args, key)
self.redraw()
return InputState.PROCESSED
def apply(self):
""" Apply our selections. """
self.data.autopart.type = self._selected_scheme_value
示例6: refresh
def refresh(self, args=None):
""" Refresh screen. """
self._load_new_devices()
EditTUISpoke.refresh(self, args)
self._container = ListColumnContainer(1, columns_width=78, spacing=1)
summary = self._summary_text()
self.window.add_with_separator(TextWidget(summary))
hostname = _("Host Name: %s\n") % self.data.network.hostname
self.window.add_with_separator(TextWidget(hostname))
current_hostname = _("Current host name: %s\n") % network.current_hostname()
self.window.add_with_separator(TextWidget(current_hostname))
# if we have any errors, display them
while len(self.errors) > 0:
self.window.add_with_separator(TextWidget(self.errors.pop()))
self._container.add(TextWidget(_("Set host name")), callback=self._set_hostname_callback)
for dev_name in self.supported_devices:
text = (_("Configure device %s") % dev_name)
self._container.add(TextWidget(text), callback=self._configure_network_interface, data=dev_name)
self.window.add_with_separator(self._container)
示例7: refresh
def refresh(self, args=None):
NormalTUISpoke.refresh(self, args)
# Join the initialization thread to block on it
# This print is foul. Need a better message display
print(_(PAYLOAD_STATUS_PROBING_STORAGE))
threadMgr.wait(THREAD_STORAGE_WATCHER)
# synchronize our local data store with the global ksdata
# Commment out because there is no way to select a disk right
# now without putting it in ksdata. Seems wrong?
#self.selected_disks = self.data.ignoredisk.onlyuse[:]
self.autopart = self.data.autopart.autopart
self._container = ListColumnContainer(1, spacing=1)
message = self._update_summary()
# loop through the disks and present them.
for disk in self.disks:
disk_info = self._format_disk_info(disk)
c = CheckboxWidget(title=disk_info, completed=(disk.name in self.selected_disks))
self._container.add(c, self._update_disk_list_callback, disk)
# if we have more than one disk, present an option to just
# select all disks
if len(self.disks) > 1:
c = CheckboxWidget(title=_("Select all"), completed=self.select_all)
self._container.add(c, self._select_all_disks_callback)
self.window.add_with_separator(self._container)
self.window.add_with_separator(TextWidget(message))
示例8: refresh
def refresh(self, args=None):
"""
The refresh method that is called every time the spoke is displayed.
It should update the UI elements according to the contents of
self.data.
:see: pyanaconda.ui.common.UIObject.refresh
:see: simpleline.render.screen.UIScreen.refresh
:param args: optional argument that may be used when the screen is
scheduled
:type args: anything
"""
super().refresh(args)
self._container = ListColumnContainer(columns=1)
# add ListColumnContainer to window (main window container)
# this will automatically add numbering and will call callbacks when required
self.window.add(self._container)
self._container.add(CheckboxWidget(title="Simple checkbox", completed=self._checked),
callback=self._checkbox_called)
self._container.add(EntryWidget(title="Unconditional input",
value=self._unconditional_input),
callback=self._get_unconditional_input)
# show conditional input only if the checkbox is checked
if self._checked:
self._container.add(EntryWidget(title="Conditional input",
value="Password set" if self._conditional_input
else ""),
callback=self._get_conditional_input)
self._window.add_separator()
示例9: refresh
def refresh(self, args=None):
""" Refresh screen. """
NormalTUISpoke.refresh(self, args)
self._container = ListColumnContainer(1, columns_width=78, spacing=1)
if not self.nm_client:
self.window.add_with_separator(TextWidget(_("Network configuration is not available.")))
return
summary = self._summary_text()
self.window.add_with_separator(TextWidget(summary))
hostname = _("Host Name: %s\n") % self._network_module.proxy.Hostname
self.window.add_with_separator(TextWidget(hostname))
current_hostname = _("Current host name: %s\n") % self._network_module.proxy.GetCurrentHostname()
self.window.add_with_separator(TextWidget(current_hostname))
# if we have any errors, display them
while len(self.errors) > 0:
self.window.add_with_separator(TextWidget(self.errors.pop()))
dialog = Dialog(_("Host Name"))
self._container.add(TextWidget(_("Set host name")), callback=self._set_hostname_callback, data=dialog)
for device_configuration in self.editable_configurations:
iface = device_configuration.device_name
text = (_("Configure device %s") % iface)
self._container.add(TextWidget(text), callback=self._ensure_connection_and_configure,
data=iface)
self.window.add_with_separator(self._container)
示例10: refresh
def refresh(self, args=None):
super().refresh(args)
self._container = ListColumnContainer(1, columns_width=78, spacing=1)
# check if the storage refresh thread is running
if threadMgr.get(THREAD_STORAGE_WATCHER):
# storage refresh is running - just report it
# so that the user can refresh until it is done
# TODO: refresh once the thread is done ?
message = _(PAYLOAD_STATUS_PROBING_STORAGE)
self.window.add_with_separator(TextWidget(message))
# check if there are any mountable devices
if self._mountable_devices:
for d in self._mountable_devices:
self._container.add(TextWidget(d[1]),
callback=self._select_mountable_device,
data=d[0])
self.window.add_with_separator(self._container)
else:
message = _("No mountable devices found")
self.window.add_with_separator(TextWidget(message))
示例11: refresh
def refresh(self, args=None):
NormalTUISpoke.refresh(self, args)
threadMgr.wait(THREAD_PAYLOAD)
self._container = ListColumnContainer(1, columns_width=78, spacing=1)
if self.data.method.method == "harddrive" and \
get_mount_device(DRACUT_ISODIR) == get_mount_device(DRACUT_REPODIR):
message = _("The installation source is in use by the installer and cannot be changed.")
self.window.add_with_separator(TextWidget(message))
return
if args == self.SET_NETWORK_INSTALL_MODE:
if self.payload.mirrors_available:
self._container.add(TextWidget(_("Closest mirror")), self._set_network_close_mirror)
self._container.add(TextWidget("http://"), self._set_network_url, SpecifyRepoSpoke.HTTP)
self._container.add(TextWidget("https://"), self._set_network_url, SpecifyRepoSpoke.HTTPS)
self._container.add(TextWidget("ftp://"), self._set_network_url, SpecifyRepoSpoke.FTP)
self._container.add(TextWidget("nfs"), self._set_network_nfs)
else:
self.window.add(TextWidget(_("Choose an installation source type.")))
self._container.add(TextWidget(_("CD/DVD")), self._set_cd_install_source)
self._container.add(TextWidget(_("local ISO file")), self._set_iso_install_source)
self._container.add(TextWidget(_("Network")), self._set_network_install_source)
if self._hmc:
self._container.add(TextWidget(_("SE/HMC")), self._set_hmc_install_source)
self.window.add_with_separator(self._container)
示例12: refresh
def refresh(self, args=None):
"""Refresh window."""
super().refresh(args)
self._container = ListColumnContainer(1)
self._add_mount_point_widget()
self._add_format_widget()
self._add_reformat_widget()
self.window.add_with_separator(self._container)
self.window.add_with_separator(TextWidget(
_("Choose from above to assign mount point and/or set format.")
))
示例13: refresh
def refresh(self, args=None):
super().refresh(args)
self.window.add_with_separator(TextWidget(self._message))
self._container = ListColumnContainer(1, spacing=1)
# choices are
# USE VNC
self._container.add(TextWidget(_(USEVNC)), self._use_vnc_callback)
# USE TEXT
self._container.add(TextWidget(_(USETEXT)), self._use_text_callback)
self.window.add_with_separator(self._container)
示例14: refresh
def refresh(self, args=None):
super().refresh(args)
self._container = ListColumnContainer(1)
for root in self._roots:
box = CheckboxWidget(
title="{} on {}".format(root.name, root.device.path),
completed=(self._selection == root)
)
self._container.add(box, self._select_root, root)
message = _("The following installations were discovered on your system.")
self.window.add_with_separator(TextWidget(message))
self.window.add_with_separator(self._container)
示例15: refresh
def refresh(self, args=None):
super().refresh(args)
summary = self._summary_text()
self.window.add_with_separator(TextWidget(summary))
self._container = ListColumnContainer(1, columns_width=78, spacing=1)
self._container.add(TextWidget(_("Add NTP server")), self._add_ntp_server)
# only add the remove option when we can remove something
if self._time_spoke.ntp_servers:
self._container.add(TextWidget(_("Remove NTP server")), self._remove_ntp_server)
self.window.add_with_separator(self._container)