def launch(self) -> None: self._set_orientation_in_profile() env = self._prep_environment() cmdline = self._make_commandline() modal_opts = api.ModalOptions( align="center", width=("relative", 90), valign="middle", height="pack", ) try: message = urwid.Text("Running XCSoar...") self.shell.screen.push_dialog("XCSoar", message).no_buttons() self.shell.screen.draw() try: completed = subprocess.run(cmdline, capture_output=True, env=env) finally: message.set_text("Finishing XCSoar...") self.shell.screen.draw() self.shell.os.sync() self.shell.screen.pop_activity() except FileNotFoundError as e: self.shell.screen.push_modal(AppOutputActivity(self.shell, str(e)), modal_opts) return if completed.returncode != 0: self.shell.screen.push_modal( AppOutputActivity(self.shell, completed.stderr.decode("utf-8")), modal_opts, )
def _get_rsync_modal_opts(self) -> api.ModalOptions: return api.ModalOptions( align="center", width=("relative", 80), valign="middle", height="pack", )
def __init__(self, screen: api.ScreenManager, title: str, message: urwid.Widget) -> None: self.screen = screen self.title = title self.message = message self.modal_opts = api.ModalOptions( align="center", width=("relative", 60), valign="middle", height="pack", min_width=54, ) self.custom_buttons = False self.button_width = 0
async def request_input( self, service: ConnmanService, fields: Dict[str, Dict[str, Any]]) -> Dict[str, Any]: # {'Passphrase': {'Type': 'psk', 'Requirement': 'mandatory'}} # {'Passphrase': {'Type': 'psk', 'Requirement': 'mandatory', 'Alternates': ['WPS']}, 'WPS': {'Type': 'wpspin', 'Requirement': 'alternate'}} act = ConnmanInputActivity(self.screen, service, fields) modal_opts = api.ModalOptions( align="center", width=("relative", 60), valign="middle", height="pack", min_width=54, ) self.screen.push_modal(act, modal_opts) result = await act.done return result
def test_push_modal() -> None: urwid_mock = UrwidMock() mainloop = mock.Mock(name="MainLoop") mainloop.screen._palette = {} screen = ScreenManagerImpl(mainloop) act1 = ActivityStub("Activity One") screen.push_activity(act1) # WHEN screen.push_modal( ActivityStub("Modal Activity"), api.ModalOptions(align="center", width=20, valign="top", height=3), ) # THEN # Modal activity does not obscure the main view view = urwid_mock.render(mainloop.widget) assert "Modal Activity" in view assert "Activity One" in view