So, I watched the tutorial which is good, but since its using Anvils database and mine is external, Iâm just not making the mental connections I need to. I am now finding this error if I have the code laid out as per the bottom of this post:-
Warning: baseprice.button_1_click does not exist. Trying to set the âclickâ event of self.button_1 from baseprice.
However, if I indent it back one, I dont get the button click warning but get this instead
NameError: name âselfâ is not defined `
*** at ServerModule1, line 28**
*** ` called from baseprice, line 26**
I think I am going backwards as well, I had the same not defined error on all the variables so declared them at the top, but they are already declared inside each function, but not as global variables.
My functions are all like this with variations on the detail, but structured the same
@anvil.server.callable
def ageQuery (currentage):
currentage = self.text_box_age.text
conn = connect()
with conn.cursor() as cur:
cur.execute("SELECT Age, AgePercent FROM age WHERE Age ={currentage}".format(currentage=currentage))
return cur.fetchall()
This is my code
class baseprice(basepriceTemplate):
def __init__(self, **properties):
# Set Form properties and Data Bindings.
self.init_components(**properties)
# Any code you write here will run when the form opens.
def button_1_click(self, **event_args):
global currentage
currentage =()
global currentdays
currentdays=()
global currentbaggage
currentbaggage=()
global currentsinglearticle
currentsinglearticle=()
global currentcancellation
currentcancellation=()
self.repeating_panel_2.items = anvil.server.call('ageQuery', currentage)
self.repeating_panel_3.items = anvil.server.call('daysQuery', currentdays)
self.repeating_panel_4.items = anvil.server.call('baggageQuery', currentbaggage)
self.repeating_panel_5.items = anvil.server.call('singlearticleQuery', currentsinglearticle)
self.repeating_panel_6.items = anvil.server.call('cancellationQuery', currentcancellation)
pass
So basically here is the result I want to achieve
I want what is input on the form by the user, to act as the variable for the function when they press submit, which will then output the matching record in my database, on the repeating panel.
Many thanks in advance