def _build_iface_inputs(self): if len(self.device.info.wlan['visible_ssids']) > 0: networks_btn = menu_btn("Choose a visible network", on_press=self.show_ssid_list) else: networks_btn = disabled(menu_btn("No visible networks")) if not self.device.info.wlan['scan_state']: scan_btn = menu_btn("Scan for networks", on_press=self.start_scan) else: scan_btn = disabled(menu_btn("Scanning for networks")) warning = ( "Only open or WPA2/PSK networks are supported at this time.") col = [ Text(warning), Text(""), self.ssid_row, Text(""), Padding.fixed_32(networks_btn), Padding.fixed_32(scan_btn), Text(""), self.psk_row, ] return col
def _build_iface_inputs(self): visible_ssids = self.dev_info.wlan.visible_ssids if len(visible_ssids) > 0: networks_btn = menu_btn("Choose a visible network", on_press=self.show_ssid_list) else: networks_btn = disabled(menu_btn("No visible networks")) scan_state = self.dev_info.wlan.scan_state if not scan_state: scan_btn = menu_btn("Scan for networks", on_press=self.start_scan) elif scan_state.startswith('error'): self.error.set_text('scan failed: %s' % (scan_state, )) scan_btn = disabled(menu_btn("Scanning for networks failed")) else: scan_btn = disabled(menu_btn("Scanning for networks")) warning = ( "Only open or WPA2/PSK networks are supported at this time.") col = [ Text(warning), Text(""), self.ssid_row, Text(""), Padding.fixed_32(networks_btn), Padding.fixed_32(scan_btn), Text(""), self.psk_row, ] return col
def __init__(self, app, report, interrupting=True): self.app = app self.report = report self.interrupting = interrupting self.btns = { 'cancel': other_btn( _("Cancel upload"), on_press=self.cancel_upload), 'close': close_btn(self, _("Close report")), 'continue': close_btn(self, _("Continue")), 'debug_shell': other_btn( _("Switch to a shell"), on_press=self.debug_shell), 'restart': other_btn( _("Restart the installer"), on_press=self.restart), 'submit': other_btn( _("Send to Canonical"), on_press=self.submit), 'submitted': disabled(other_btn(_("Sent to Canonical"))), 'view': other_btn( _("View full report"), on_press=self.view_report), } w = 0 for n, b in self.btns.items(): w = max(w, widget_width(b)) for n, b in self.btns.items(): self.btns[n] = Padding(b, width=w, align='center') self.spinner = Spinner(app.aio_loop, style='dots') self.pile = Pile([]) self._report_changed() super().__init__("", [self.pile], 0, 0) connect_signal(self, 'closed', self.spinner.stop)
def show_overlay(self, overlay_widget, **kw): args = dict( align='center', width=('relative', 60), min_width=80, valign='middle', height='pack' ) PADDING = 3 # Don't expect callers to account for the padding if # they pass a fixed width. if 'width' in kw: if isinstance(kw['width'], int): kw['width'] += 2*PADDING args.update(kw) top = Pile([ ('pack', Text("")), Columns([ (PADDING, Text("")), overlay_widget, (PADDING, Text("")) ]), ('pack', Text("")), ]) self._w = Overlay(top_w=top, bottom_w=disabled(self._w), **args)
def __init__(self, app, ref, interrupting=True): self.app = app self.error_ref = ref self.report = app.error_reporter.get(ref) self.pending = None if self.report is None: self.app.aio_loop.create_task(self._wait()) else: connect_signal(self.report, 'changed', self._report_changed) self.report.mark_seen() self.interrupting = interrupting self.min_wait = self.app.aio_loop.create_task(asyncio.sleep(0.1)) self.btns = { 'cancel': other_btn(_("Cancel upload"), on_press=self.cancel_upload), 'close': close_btn(self, _("Close report")), 'continue': close_btn(self, _("Continue")), 'debug_shell': other_btn(_("Switch to a shell"), on_press=self.debug_shell), 'restart': other_btn(_("Restart the installer"), on_press=self.restart), 'submit': other_btn(_("Send to Canonical"), on_press=self.submit), 'submitted': disabled(other_btn(_("Sent to Canonical"))), 'view': other_btn(_("View full report"), on_press=self.view_report), } w = 0 for n, b in self.btns.items(): w = max(w, widget_width(b)) for n, b in self.btns.items(): self.btns[n] = Padding(b, width=w, align='center') self.spinner = Spinner(app.aio_loop, style='dots') self.pile = Pile([]) self.pile.contents[:] = [(w, self.pile.options('pack')) for w in self._pile_elements()] super().__init__("", [self.pile], 0, 0) connect_signal(self, 'closed', self.spinner.stop)
def enabled(self, val): if val and not self._enabled: self.original_widget = self.original elif not val and self._enabled: self.original_widget = disabled(self.original) self._enabled = val
def show_stretchy_overlay(self, stretchy): emit_signal(stretchy, 'opened') stretchy.opened() self._w = StretchyOverlay(disabled(self._w), stretchy)
def disable(self): if self.enabled: self.original_widget = disabled(self.original) self.enabled = False
def show_stretchy_overlay(self, stretchy): self._w = StretchyOverlay(disabled(self._w), stretchy)