Hi!
I’m currently making a real-time poll application, modeling after the SMS Polling App example, and when I run my app, there’s a white circle with blue dots cycling in a counter-clockwise formation.
Is there an option to remove this?
Hi!
I’m currently making a real-time poll application, modeling after the SMS Polling App example, and when I run my app, there’s a white circle with blue dots cycling in a counter-clockwise formation.
Is there an option to remove this?
Hi there!
Yes, you can do this
Normally, Anvil shows the spinner whenever you’re talking to the server (eg doing an anvil.server.call()
or searching a data table). But if you call a server function with anvil.server.call_s()
, the spinner won’t show (the S is for “silent”).
Worked example:
Let’s imagine we have a label on our form, and we’re updating it every second with the number of rows in the table. So we’re doing something like this:
def update_timer_tick (self, **event_args):
# This method is called every second
n_rows = len(app_tables.my_table.search())
self.label_1.text = "There are %d rows" % n_rows
Then we will see the blue spinner every second as we search app_tables.my_table
. We don’t want this, so instead we write a server function that extracts our data for us, and we call it with anvil.server.call_s()
:
# Put this code in a new Server Module:
@anvil.server.callable
def get_n_rows():
return len(app_tables.my_table.search())
And now we change the code in our Form to this:
def update_timer_tick (self, **event_args):
# This method is called every second
n_rows = anvil.server.call_s('get_n_rows')
self.label_1.text = "There are %d rows" % n_rows
Now we won’t see the blue spinner.
Does this make sense?
Yes, I was able to get this to work! Thank you for the working example!