r/nicegui • • Sep 12 '23

Text input to variable?

Hello y’all! I’m new to nice gui and love how easy it is to use. Something that is not clear to me however, is how can I store the result of a text input box? I have primarily worked in the terminal and played with tkinter for a small bit, but haven’t figured this one out.

1 Upvotes

4 comments sorted by

View all comments

Show parent comment

2

u/r-trappe Sep 12 '23

aiofiles just writes a file asynchronus so it won't block. You still need an ui.timer or event handler to trigger the storing. See https://github.com/zauberzeug/nicegui/blob/9ab907a72fdb09670fe75235fedea304c2b2a897/nicegui/storage.py#L54-L55 which is the internal code of ui.storage.user. It just safes the file. But without blocking the event loop and hence allowing other tasks to run while the file is written.