Last active
February 6, 2023 18:06
-
-
Save vlkorsakov/d69e2cc2e6f738f22e79fa67282cb66a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dialog = Dialog( | |
Window( | |
Const("Записи:"), | |
Format("{records}"), | |
Row( | |
Button(Const("<"), id="prev_records", on_click=prev_records), | |
Button(Const(">"), id="next_records", on_click=next_records), | |
), | |
Cancel(Const("Close btn")), | |
state=RecordsSG.SHOW, | |
getter=get_records, | |
), | |
) | |
async def prev_records(_, __, manager: DialogManager): | |
offset = manager.dialog_data.get("offset", 0) | |
manager.dialog_data.update(offset=offset - 5) | |
async def next_records(_, __, manager: DialogManager): | |
offset = manager.dialog_data.get("offset", 0) | |
manager.dialog_data.update(offset=offset - 5) | |
async def get_records(dialog_manager: DialogManager, repo: Repo, **_): | |
offset = dialog_manager.dialog_data.get("offset", 0) | |
records = await repo.get_records(offset=offset, limit=5) | |
return { | |
"records": "\n".join(records) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment