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))
def refresh(self, args=None): """Prepare the content of the screen.""" super().refresh(args) threadMgr.wait(THREAD_STORAGE_WATCHER) # Get the available partitioning. object_path = self._storage_module.CreatedPartitioning[-1] self._partitioning = STORAGE.get_proxy(object_path) # Create a new container. self._container = ListColumnContainer(1, spacing=1) # loop through the disks and present them. for disk_name in self._available_disks: disk_info = self._format_disk_info(disk_name) c = CheckboxWidget(title=disk_info, completed=(disk_name in self._selected_disks)) self._container.add(c, self._update_disk_list_callback, disk_name) # if we have more than one disk, present an option to just # select all disks if len(self._available_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(self._update_summary()))
def refresh(self, args=None): super().refresh() # Text widget # Show text to user. This is basic widget which will handle # wrapping of words for you. text_widget = TextWidget("Text widget") self.window.add_with_separator(text_widget) # Center widget # Wrap extisting widget and center it to the middle of the screen. text = TextWidget("Center widget") center_widget = CenterWidget(text) self.window.add_with_separator( center_widget, blank_lines=3) # Add two more blank lines # Checkbox widget # Checkbox which can hold 2 states. checkbox_widget = CheckboxWidget(key="o", title="Checkbox title", text="Checkbox text", completed=True) self.window.add_with_separator(checkbox_widget) # Checkbox widget unchecked checkbox_widget_unchecked = CheckboxWidget(key="o", title="Checkbox title", text="Unchecked", completed=False) self.window.add_with_separator(checkbox_widget_unchecked)
def test_checkbox_wrapping(self): checkbox = CheckboxWidget(title="Title", text="Testing\nwrapping") checkbox.render(80) expected_result = [u"[ ] Title", u" (Testing", u" wrapping)"] self.evaluate_result(checkbox.get_lines(), expected_result)
def test_checkbox(self): checkbox = CheckboxWidget(title="Test Title", text="Description") checkbox.render(80) expected_result = [u"[ ] Test Title", u" (Description)"] self.evaluate_result(checkbox.get_lines(), expected_result)
def test_empty_checkbox(self): checkbox = CheckboxWidget() checkbox.render(80) expected_result = [u"[ ]"] self.evaluate_result(checkbox.get_lines(), expected_result)
def test_key_checkbox(self): checkbox = CheckboxWidget(key="o", title="Title", text="Description", completed=True) checkbox.render(80) expected_result = [u"[o] Title", u" (Description)"] self.evaluate_result(checkbox.get_lines(), expected_result)
def refresh(self, args=None): """ Refresh window. """ super().refresh(args) self._container = ListColumnContainer(1) dialog = Dialog(title=(_('IPv4 address or %s for DHCP') % '"dhcp"'), conditions=[self._check_ipv4_or_dhcp]) self._container.add(EntryWidget(dialog.title, self.network_data.ip), self._set_ipv4_or_dhcp, dialog) dialog = Dialog(title=_("IPv4 netmask"), conditions=[self._check_netmask]) self._container.add( EntryWidget(dialog.title, self.network_data.netmask), self._set_netmask, dialog) dialog = Dialog(title=_("IPv4 gateway"), conditions=[self._check_ipv4]) self._container.add( EntryWidget(dialog.title, self.network_data.gateway), self._set_ipv4_gateway, dialog) msg = (_( 'IPv6 address[/prefix] or %(auto)s for automatic, %(dhcp)s for DHCP, ' '%(ignore)s to turn off') % { "auto": '"auto"', "dhcp": '"dhcp"', "ignore": '"ignore"' }) dialog = Dialog(title=msg, conditions=[self._check_ipv6_config]) self._container.add(EntryWidget(dialog.title, self.network_data.ipv6), self._set_ipv6, dialog) dialog = Dialog(title=_("IPv6 default gateway"), conditions=[self._check_ipv6]) self._container.add( EntryWidget(dialog.title, self.network_data.ipv6gateway), self._set_ipv6_gateway, dialog) dialog = Dialog(title=_("Nameservers (comma separated)"), conditions=[self._check_nameservers]) self._container.add( EntryWidget(dialog.title, self.network_data.nameserver), self._set_nameservers, dialog) msg = _("Connect automatically after reboot") w = CheckboxWidget(title=msg, completed=self.network_data.onboot) self._container.add(w, self._set_onboot_handler) msg = _("Apply configuration in installer") w = CheckboxWidget(title=msg, completed=self.apply_configuration) self._container.add(w, self._set_apply_handler) self.window.add_with_separator(self._container) message = _("Configuring device %s.") % self.network_data.device self.window.add_with_separator(TextWidget(message))
def refresh(self, args=None): NormalTUISpoke.refresh(self, args) self._container = ListColumnContainer(1) mount_point_title = _("Mount point") reformat_title = _("Reformat") none_msg = _("none") fmt = get_format(self._mount_data.format) if fmt and fmt.mountable: dialog = Dialog(mount_point_title, conditions=[self._check_assign_mount_point]) value = self._mount_data.mount_point or none_msg self._container.add(EntryWidget(dialog.title, value), self._assign_mount_point, dialog) elif fmt and fmt.type is None: # mount point cannot be set for no format # (fmt.name = "Uknown" in this case which would look weird) self._container.add(EntryWidget(mount_point_title, none_msg), lambda x: self.redraw()) else: # mount point cannot be set for format that is not mountable, just # show the format's name in square brackets instead self._container.add(EntryWidget(mount_point_title, fmt.name), lambda x: self.redraw()) dialog = Dialog(_("Format"), conditions=[self._check_format]) value = self._mount_data.format or none_msg self._container.add(EntryWidget(dialog.title, value), self._set_format, dialog) if ((self._mount_data.orig_format and self._mount_data.orig_format != self._mount_data.format) or self._mount_data.mount_point == "/"): # changing format implies reformat and so does "/" mount point self._container.add( CheckboxWidget(title=reformat_title, completed=self._mount_data.reformat)) else: self._container.add( CheckboxWidget(title=reformat_title, completed=self._mount_data.reformat), self._switch_reformat) self.window.add_with_separator(self._container) self.window.add_with_separator( TextWidget( _("Choose from above to assign mount point and/or set format.") ))
def refresh(self, args=None): NormalTUISpoke.refresh(self, args) # refresh the user list self._user_list = get_user_list(self._users_module, add_default=True, add_if_not_empty=self._user_cleared) self._is_admin = self.user.has_admin_priviledges() self._groups = ", ".join(self.user.groups) self._container = ListColumnContainer(1) w = CheckboxWidget(title=_("Create user"), completed=self._create_user) self._container.add(w, self._set_create_user) if self._create_user: dialog = Dialog(title=_("Full name"), conditions=[self._check_fullname]) self._container.add(EntryWidget(dialog.title, self.user.gecos), self._set_fullname, dialog) dialog = Dialog(title=_("User name"), conditions=[self._check_username]) self._container.add(EntryWidget(dialog.title, self.user.name), self._set_username, dialog) w = CheckboxWidget(title=_("Use password"), completed=self._use_password) self._container.add(w, self._set_use_password) if self._use_password: password_dialog = PasswordDialog( title=_("Password"), policy_name=PASSWORD_POLICY_USER) if self.user.password: entry = EntryWidget(password_dialog.title, _(PASSWORD_SET)) else: entry = EntryWidget(password_dialog.title) self._container.add(entry, self._set_password, password_dialog) msg = _("Administrator") w = CheckboxWidget(title=msg, completed=self._is_admin) self._container.add(w, self._set_administrator) dialog = Dialog(title=_("Groups"), conditions=[self._check_groups]) self._container.add(EntryWidget(dialog.title, self._groups), self._set_groups, dialog) self.window.add_with_separator(self._container)
def refresh(self, args=None): """ Refresh screen. """ NormalTUISpoke.refresh(self, args) threadMgr.wait(THREAD_PAYLOAD) self._container = None if not self.payload.baseRepo: message = TextWidget( _("Installation source needs to be set up first.")) self.window.add_with_separator(message) return threadMgr.wait(THREAD_CHECK_SOFTWARE) self._container = ListColumnContainer(2, columns_width=38, spacing=2) # Display the environments if args is None: environments = self.payload.environments msg = _("Base environment") for env in environments: name = self.payload.environmentDescription(env)[0] selected = (env == self._selected_environment) widget = CheckboxWidget(title="%s" % name, completed=selected) self._container.add(widget, callback=self._set_environment_callback, data=env) # Display the add-ons else: length = len(args) if length > 0: msg = _("Add-ons for selected environment") else: msg = _("No add-ons to select.") for addon_id in args: name = self.payload.groupDescription(addon_id)[0] selected = addon_id in self._addons_selection widget = CheckboxWidget(title="%s" % name, completed=selected) self._container.add(widget, callback=self._set_addons_callback, data=addon_id) self.window.add_with_separator(TextWidget(msg)) self.window.add_with_separator(self._container)
def _create_fadump_checkbox(self): if not os.path.exists(FADUMP_CAPABLE_FILE): return enable_fadump_checkbox = CheckboxWidget(title=_("Enable dump mode fadump"), completed=self._addon_data.enablefadump) self._container.add(enable_fadump_checkbox, self._set_fadump_enable)
def _add_reformat_widget(self): """Add a widget for reformat.""" widget = CheckboxWidget( title=_("Reformat"), completed=self._request.reformat ) self._container.add(widget, self._switch_reformat)
def refresh(self, args=None): """Refresh the screen.""" NormalTUISpoke.refresh(self, args) self._container = ListColumnContainer(columns=2, columns_width=38, spacing=2) for group in self._selection_cache.available_groups: data = self._dnf_manager.get_group_data(group) selected = self._selection_cache.is_group_selected(group) widget = CheckboxWidget(title=data.name, completed=selected) self._container.add(widget, callback=self._select_group, data=data.id) if self._selection_cache.available_groups: msg = _("Additional software for selected environment") else: msg = _("No additional software to select.") self.window.add_with_separator(TextWidget(msg)) self.window.add_with_separator(self._container)
def refresh(self, args=None): """ Refresh screen. """ NormalTUISpoke.refresh(self, args) self._container = None if not self._source_is_set: message = TextWidget( _("Installation source needs to be set up first.")) self.window.add_with_separator(message) return threadMgr.wait(THREAD_CHECK_SOFTWARE) self._container = ListColumnContainer(columns=2, columns_width=38, spacing=2) for environment in self._selection_cache.available_environments: data = self._dnf_manager.get_environment_data(environment) selected = self._selection_cache.is_environment_selected( environment) widget = CheckboxWidget(title=data.name, completed=selected) self._container.add(widget, callback=self._select_environment, data=data.id) self.window.add_with_separator(TextWidget(_("Base environment"))) self.window.add_with_separator(self._container) if self._errors or self._warnings: messages = "\n".join(self._errors or self._warnings) self.window.add_with_separator(TextWidget(messages))
def refresh(self, args=None): super().refresh() self.os_num_range = range(1, len(args) + 1) self.key_list = [] for k in self.os_num_range: self.key_list.append(str(k)) os_column = ListColumnContainer(columns=1, numbering=True) for os_config in args: vm_osinfo_id = os_config["vm_osinfo_id"] vm_cloud_image = os_config["vm_cloud_image"] if KVMHolder.selected_os != None and ( KVMHolder.selected_os["vm_osinfo_id"] == vm_osinfo_id): os_completed = True else: os_completed = False os_text = "{0} - {1}".format(vm_osinfo_id, vm_cloud_image) tmp_widget = CheckboxWidget(key='x', title=vm_osinfo_id, text=vm_cloud_image, completed=os_completed) os_column.add(tmp_widget) self.window.add(os_column)
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 text 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 password input", value="Password set" if self._conditional_input else ""), callback=self._get_conditional_input) self._window.add_separator()
def _add_reformat_widget(self): """Add a widget for reformat.""" widget = CheckboxWidget( title=_("Reformat"), completed=self._mount_data[MOUNT_POINT_REFORMAT] ) self._container.add(widget, self._switch_reformat)
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 """ # call parent method to setup basic container with screen title set super().refresh(args) self._reverse = self._hello_world_module.Reverse self._entered_text = "".join(self._hello_world_module.Lines) self._container = ListColumnContainer(columns=1) self.window.add(self._container) self._container.add(CheckboxWidget(title="Reverse", completed=self._reverse), callback=self._change_reverse) self._container.add(EntryWidget(title="Hello world text", value=self._entered_text), callback=self._change_lines) self._window.add_separator()
def render(self, width): """Render the summary representation for Hub to internal buffer.""" Widget.render(self, width) if self.mandatory and not self.completed: key = "!" elif self.completed: key = "x" else: key = " " # always set completed = True here; otherwise key value won't be # displayed if completed (spoke value from above) is False c = CheckboxWidget(key=key, completed=True, title=_(self.title), text=self.status) c.render(width) self.draw(c)
def refresh(self, args=None): NormalTUISpoke.refresh(self, args) self._is_admin = "wheel" in self._user_data.groups self._groups = ", ".join(self._user_data.groups) self._container = ListColumnContainer(1) w = CheckboxWidget(title=_("Create user"), completed=self._create_user) self._container.add(w, self._set_create_user) if self._create_user: dialog = Dialog(title=_("Full name"), conditions=[self._check_fullname]) self._container.add( EntryWidget(dialog.title, self._user_data.gecos), self._set_fullname, dialog) dialog = Dialog(title=_("User name"), conditions=[self._check_username]) self._container.add( EntryWidget(dialog.title, self._user_data.name), self._set_username, dialog) w = CheckboxWidget(title=_("Use password"), completed=self._use_password) self._container.add(w, self._set_use_password) if self._use_password: password_dialog = PasswordDialog(title=_("Password"), policy=self._policy) if self._user_data.password: entry = EntryWidget(password_dialog.title, _(PASSWORD_SET)) else: entry = EntryWidget(password_dialog.title) self._container.add(entry, self._set_password, password_dialog) msg = _("Administrator") w = CheckboxWidget(title=msg, completed=self._is_admin) self._container.add(w, self._set_administrator) dialog = Dialog(title=_("Groups"), conditions=[self._check_groups]) self._container.add(EntryWidget(dialog.title, self._groups), self._set_groups, dialog) self.window.add_with_separator(self._container)
def refresh(self, args=None): NormalTUISpoke.refresh(self, args) self._container = ListColumnContainer(1) for part_type in self.parttypelist: c = CheckboxWidget(title=_(part_type), completed=(not self._do_mount_assign and PARTTYPES[part_type] == self.clearPartType)) self._container.add(c, self._select_partition_type_callback, part_type) c = CheckboxWidget(title=_("Manually assign mount points") + _(" (EXPERIMENTAL)"), completed=self._do_mount_assign) self._container.add(c, self._select_mount_assign) self.window.add_with_separator(self._container) message = _("Installation requires partitioning of your hard drive. " "Select what space to use for the install target or manually assign mount points.") self.window.add_with_separator(TextWidget(message))
def _refresh_environments(self): environments = self.payload.environments for env in environments: name = self.payload.environment_description(env)[0] selected = (env == self._selected_environment) widget = CheckboxWidget(title="%s" % name, completed=selected) self._container.add(widget, callback=self._set_environment_callback, data=env) return _("Base environment")
def _refresh_addons(self, available_addons): for addon_id in available_addons: name = self.payload.group_description(addon_id)[0] selected = addon_id in self._addons_selection widget = CheckboxWidget(title="%s" % name, completed=selected) self._container.add(widget, callback=self._set_addons_callback, data=addon_id) if available_addons: return _("Additional software for selected environment") else: return _("No additional software to select.")
def refresh(self, args=None): super().refresh(args) message = _("The following installations were discovered on your system.\n") self.window.add_with_separator(TextWidget(message)) for i, root_desc in enumerate(self._roots): root_name, root_device_path = root_desc box = CheckboxWidget(title="%i) %s on %s" % (i + 1, _(root_name), root_device_path), completed=(self._selection == i)) self.window.add_with_separator(box)
def refresh(self, args=None): """Prepare the content of the screen.""" super().refresh(args) # Create a new container. self._container = ListColumnContainer(1, spacing=1) # loop through the disks and present them. for disk_name in self._available_disks: disk_info = self._format_disk_info(disk_name) c = CheckboxWidget(title=disk_info, completed=(disk_name in self._selected_disks)) self._container.add(c, self._update_disk_list_callback, disk_name) # if we have more than one disk, present an option to just # select all disks if len(self._available_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(self._update_summary()))
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 refresh(self, args=None): super().refresh(args) self._container = ListColumnContainer(1) for init_mode in self._init_mode_list: c = CheckboxWidget(title=_(init_mode), completed=( self._part_method == PARTITIONING_METHOD_AUTOMATIC and self._init_mode == INIT_MODES[init_mode] )) self._container.add(c, self._select_partition_type_callback, init_mode) c = CheckboxWidget(title=_("Manually assign mount points"), completed=( self._part_method == PARTITIONING_METHOD_MANUAL )) self._container.add(c, self._select_mount_assign) self.window.add_with_separator(self._container) message = _("Installation requires partitioning of your hard drive. " "Select what space to use for the install target or " "manually assign mount points.") self.window.add_with_separator(TextWidget(message))
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 refresh(self, args=None): NormalTUISpoke.refresh(self, args) self._container = ListRowContainer(1) log.debug("license found") # make the options aligned to the same column (the checkbox has the # '[ ]' prepended) self._container.add( TextWidget("%s\n" % _("Read the License Agreement")), self._show_license_screen_callback) self._container.add( CheckboxWidget(title=_("I accept the license agreement."), completed=self.data.eula.agreed), self._license_accepted_callback) self.window.add_with_separator(self._container)