I’m trying to build a minimal ‘proof of concept’ form.
The idea is three items that are randomly chose from three lists. The text for that item appears on the form. If you press the button by that item, they are re-chosen.
I can return the text to the ‘output pane’ using print. I’ve done the ‘todo list’ tutorial, but I don’t really want to create a huge datatable merely to return the text. I don’t need memory between sessions or a scrolling down list of previously generated combinations.
I want the form to stay graphically static without popups, so not able to use the alert() option
Binding the returned string to a label does not seem to work either.
@patbrry and for the interactive bit of your question, you could set a button’s click event to trigger a function that makes your random selections and pipes the text to the labels on your form as @david.wylie suggested.
In the IDE, write a function name in the “events” pane (or just click the arrow and Anvil will set one up for you).
Just for the sake of example, if your lists are contained in text boxes on your form, then to randomly choose from each list via a button click, something similar to this could work.
import random
.
.
.
def button_1_click(self, **event_args):
.
.
.
a,b,c=[random.choice(x)
for x in [list_1,list_2,list_3]]
self.label_1.text=a
self.label_2.text=b
self.label_3.text=c