bastd.ui.telnet

UI functionality for telnet access.

 1# Released under the MIT License. See LICENSE for details.
 2#
 3"""UI functionality for telnet access."""
 4
 5from __future__ import annotations
 6
 7import _ba
 8import ba
 9
10
11class TelnetAccessRequestWindow(ba.Window):
12    """Window asking the user whether to allow a telnet connection."""
13
14    def __init__(self) -> None:
15        width = 400
16        height = 100
17        text = ba.Lstr(resource='telnetAccessText')
18
19        uiscale = ba.app.ui.uiscale
20        super().__init__(root_widget=ba.containerwidget(
21            size=(width, height + 40),
22            transition='in_right',
23            scale=(1.7 if uiscale is ba.UIScale.SMALL else
24                   1.3 if uiscale is ba.UIScale.MEDIUM else 1.0)))
25        padding = 20
26        ba.textwidget(parent=self._root_widget,
27                      position=(padding, padding + 33),
28                      size=(width - 2 * padding, height - 2 * padding),
29                      h_align='center',
30                      v_align='top',
31                      text=text)
32        btn = ba.buttonwidget(parent=self._root_widget,
33                              position=(20, 20),
34                              size=(140, 50),
35                              label=ba.Lstr(resource='denyText'),
36                              on_activate_call=self._cancel)
37        ba.containerwidget(edit=self._root_widget, cancel_button=btn)
38        ba.containerwidget(edit=self._root_widget, selected_child=btn)
39
40        ba.buttonwidget(parent=self._root_widget,
41                        position=(width - 155, 20),
42                        size=(140, 50),
43                        label=ba.Lstr(resource='allowText'),
44                        on_activate_call=self._ok)
45
46    def _cancel(self) -> None:
47        ba.containerwidget(edit=self._root_widget, transition='out_right')
48        _ba.set_telnet_access_enabled(False)
49
50    def _ok(self) -> None:
51        ba.containerwidget(edit=self._root_widget, transition='out_left')
52        _ba.set_telnet_access_enabled(True)
53        ba.screenmessage(ba.Lstr(resource='telnetAccessGrantedText'))
class TelnetAccessRequestWindow(ba.ui.Window):
12class TelnetAccessRequestWindow(ba.Window):
13    """Window asking the user whether to allow a telnet connection."""
14
15    def __init__(self) -> None:
16        width = 400
17        height = 100
18        text = ba.Lstr(resource='telnetAccessText')
19
20        uiscale = ba.app.ui.uiscale
21        super().__init__(root_widget=ba.containerwidget(
22            size=(width, height + 40),
23            transition='in_right',
24            scale=(1.7 if uiscale is ba.UIScale.SMALL else
25                   1.3 if uiscale is ba.UIScale.MEDIUM else 1.0)))
26        padding = 20
27        ba.textwidget(parent=self._root_widget,
28                      position=(padding, padding + 33),
29                      size=(width - 2 * padding, height - 2 * padding),
30                      h_align='center',
31                      v_align='top',
32                      text=text)
33        btn = ba.buttonwidget(parent=self._root_widget,
34                              position=(20, 20),
35                              size=(140, 50),
36                              label=ba.Lstr(resource='denyText'),
37                              on_activate_call=self._cancel)
38        ba.containerwidget(edit=self._root_widget, cancel_button=btn)
39        ba.containerwidget(edit=self._root_widget, selected_child=btn)
40
41        ba.buttonwidget(parent=self._root_widget,
42                        position=(width - 155, 20),
43                        size=(140, 50),
44                        label=ba.Lstr(resource='allowText'),
45                        on_activate_call=self._ok)
46
47    def _cancel(self) -> None:
48        ba.containerwidget(edit=self._root_widget, transition='out_right')
49        _ba.set_telnet_access_enabled(False)
50
51    def _ok(self) -> None:
52        ba.containerwidget(edit=self._root_widget, transition='out_left')
53        _ba.set_telnet_access_enabled(True)
54        ba.screenmessage(ba.Lstr(resource='telnetAccessGrantedText'))

Window asking the user whether to allow a telnet connection.

TelnetAccessRequestWindow()
15    def __init__(self) -> None:
16        width = 400
17        height = 100
18        text = ba.Lstr(resource='telnetAccessText')
19
20        uiscale = ba.app.ui.uiscale
21        super().__init__(root_widget=ba.containerwidget(
22            size=(width, height + 40),
23            transition='in_right',
24            scale=(1.7 if uiscale is ba.UIScale.SMALL else
25                   1.3 if uiscale is ba.UIScale.MEDIUM else 1.0)))
26        padding = 20
27        ba.textwidget(parent=self._root_widget,
28                      position=(padding, padding + 33),
29                      size=(width - 2 * padding, height - 2 * padding),
30                      h_align='center',
31                      v_align='top',
32                      text=text)
33        btn = ba.buttonwidget(parent=self._root_widget,
34                              position=(20, 20),
35                              size=(140, 50),
36                              label=ba.Lstr(resource='denyText'),
37                              on_activate_call=self._cancel)
38        ba.containerwidget(edit=self._root_widget, cancel_button=btn)
39        ba.containerwidget(edit=self._root_widget, selected_child=btn)
40
41        ba.buttonwidget(parent=self._root_widget,
42                        position=(width - 155, 20),
43                        size=(140, 50),
44                        label=ba.Lstr(resource='allowText'),
45                        on_activate_call=self._ok)
Inherited Members
ba.ui.Window
get_root_widget