What I’m trying to do:
Create and use a dictionary equal to self.item.
What I’ve Tried and What’s Not Working:
I tried to create it directly in the form and finally I created the variables I need to customize the form.
Code sample:
# this is a formatted code snippet.
# paste your code between
from ._anvil_designer import ModalIntegracaoTemplate
from anvil import *
import anvil.server
import anvil.google.auth, anvil.google.drive
from anvil.google.drive import app_files
import anvil.users
import anvil.tables as tables
import anvil.tables.query as q
from anvil.tables import app_tables
class ModalIntegracao(ModalIntegracaoTemplate):
def __init__(self, **properties):
# Set Form properties and Data Bindings.
self.init_components(**properties)
self.origem = anvil.server.call('dadosOrigem',self.item)
print(origem)
It’s because the text property is trying to run off self.origem before you set self.origem in init function. You can make the component a custom component and give it the object value.
Then you’ll need to create property getter setters for the property too, otherwise you’ll still get the error since that key may not always exist:
If my form’s components depend on such a value, then I set it before calling self.init_components(**properties), not after.
Otherwise, I generally do it in the form_show event handler.
form_show may be called more than once. If this is a problem in your case, then you may want to set a flag when done, so it can know to return early.
1 Like
Perfect. It opened my mind.
When you click on the link, I query the database and store the result in origin. Then just pass the origin as the second attribute when opening the form.
Thank you very much. Good weekend to everyone.