trezor-core/src/trezor/ui/entry_select.py

30 lines
805 B
Python

from micropython import const
from trezor import loop
from trezor import ui
from trezor.ui import Widget
from trezor.ui.button import Button, BTN_CLICKED
DEVICE = const(0)
HOST = const(1)
class EntrySelector(Widget):
def __init__(self, content):
self.content = content
self.device = Button(ui.grid(8, n_y=4, n_x=4, cells_x=4), 'Device')
self.host = Button(ui.grid(12, n_y=4, n_x=4, cells_x=4), 'Host')
def render(self):
self.device.render()
self.host.render()
def touch(self, event, pos):
if self.device.touch(event, pos) == BTN_CLICKED:
return DEVICE
if self.host.touch(event, pos) == BTN_CLICKED:
return HOST
async def __iter__(self):
return await loop.wait(super().__iter__(), self.content)