mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-05-06 17:09:11 +00:00
Allow parameters to layout functions
This commit is contained in:
parent
46353ed2e1
commit
f2703f1af2
@ -1,7 +1,9 @@
|
|||||||
|
import sys
|
||||||
|
|
||||||
_new_layout = None
|
_new_layout = None
|
||||||
_current_layout = None
|
_current_layout = None
|
||||||
|
|
||||||
def change_layout(layout):
|
def change(layout):
|
||||||
global _new_layout
|
global _new_layout
|
||||||
|
|
||||||
print("Changing layout to %s" % layout)
|
print("Changing layout to %s" % layout)
|
||||||
@ -9,27 +11,26 @@ def change_layout(layout):
|
|||||||
|
|
||||||
yield _current_layout.throw(StopIteration())
|
yield _current_layout.throw(StopIteration())
|
||||||
|
|
||||||
def set_main_layout(main_layout):
|
def set_main(main_layout):
|
||||||
global _new_layout
|
global _new_layout
|
||||||
global _current_layout
|
global _current_layout
|
||||||
|
|
||||||
layout = main_layout
|
_current_layout = main_layout
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
_current_layout = layout()
|
_current_layout = yield from _current_layout
|
||||||
layout = yield from _current_layout
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("Layout thrown exception %s" % str(e))
|
sys.print_exception(e)
|
||||||
_current_layout = main_layout
|
_current_layout = main_layout
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if _new_layout != None:
|
if _new_layout != None:
|
||||||
print("Switching to new layout %s" % _new_layout)
|
print("Switching to new layout %s" % _new_layout)
|
||||||
layout = _new_layout
|
_current_layout = _new_layout
|
||||||
_new_layout = None
|
_new_layout = None
|
||||||
|
|
||||||
elif layout == None:
|
elif not callable(_current_layout):
|
||||||
print("Switching to main layout %s" % main_layout)
|
print("Switching to main layout %s" % main_layout)
|
||||||
layout = main_layout
|
_current_layout = main_layout
|
||||||
else:
|
else:
|
||||||
print("Switching to proposed layout %s" % layout)
|
print("Switching to proposed layout %s" % _current_layout)
|
||||||
|
Loading…
Reference in New Issue
Block a user