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

38 lines
1.1 KiB
Python
Raw Normal View History

2017-11-03 09:14:01 -07:00
from micropython import const
from trezor import loop
2018-01-11 10:44:56 -08:00
from trezor import ui
2017-11-03 09:14:01 -07:00
from trezor.ui import Widget
2018-01-11 10:44:56 -08:00
from trezor.ui.button import Button, BTN_CLICKED
_W12 = const(12)
_W18 = const(18)
_W24 = const(24)
2017-11-03 09:14:01 -07:00
class WordSelector(Widget):
def __init__(self, content):
self.content = content
self.w12 = Button(ui.grid(6, n_y=4, n_x=3, cells_y=2), str(_W12),
2018-01-23 06:40:20 -08:00
style=ui.BTN_KEY)
self.w18 = Button(ui.grid(7, n_y=4, n_x=3, cells_y=2), str(_W18),
2018-01-23 06:40:20 -08:00
style=ui.BTN_KEY)
self.w24 = Button(ui.grid(8, n_y=4, n_x=3, cells_y=2), str(_W24),
2018-01-23 06:40:20 -08:00
style=ui.BTN_KEY)
2017-11-03 09:14:01 -07:00
def render(self):
self.w12.render()
self.w18.render()
self.w24.render()
def touch(self, event, pos):
if self.w12.touch(event, pos) == BTN_CLICKED:
2018-01-11 10:44:56 -08:00
return _W12
2017-11-03 09:14:01 -07:00
if self.w18.touch(event, pos) == BTN_CLICKED:
2018-01-11 10:44:56 -08:00
return _W18
2017-11-03 09:14:01 -07:00
if self.w24.touch(event, pos) == BTN_CLICKED:
2018-01-11 10:44:56 -08:00
return _W24
2017-11-03 09:14:01 -07:00
async def __iter__(self):
return await loop.wait(super().__iter__(), self.content)