Part 4 β State and Data [Mutable Fields]
In this part, you will learn how to change the values of state and data fields. And how they can be used in the application.
Table of contents
Step 1 β Mutable state && data fields
Remember the Part 6 State Machine?
But what if we want to change the value of the timer?
For these purposes, we have two types of fields available:
state β for storing lightweight values
data β for storing heavyweight values
In order to use mutable fields while the application is running:
All required fields must be initialized before calling
app.runFields keys must be written in
CamelCaseregisterdatafields can't read the values of widgets, so for widgets you need to usestate
src/main.py (partially)
Step 2 β GET && SET field
To get or set field, we need to refer to the api of the application.
Here's a simple example:
src/main.py (partially)
Step 3 β Results
Let's run the app and take a look at our improved timer!
\
Last updated
Was this helpful?