I would like to add a dollar sign in front of a text box that has a data binding. This is what I have so far in the data binding box within the properties:
"$%s"%(self.item['reg_price'])
But it gives me this error when I run
ValueError: invalid literal for int() with base 10: '$55'
Any idea what I’m doing wrong here?
It makes even less sense to me because I got this one to work:
"%s%% OFF"%(self.item['percent_discount'])
Which gives me the correct desired output of “55% OFF”
Just a guess, but the dollar sign is used in regex - maybe escape it?
1 Like
Sorry I’m just not sure about the syntax to escape a regex character
I tried:
“%$%s”,%(self.item[‘reg_price’])
“$%%s”,%(self.item[‘reg_price’])
“%s%s”,%("$",self.item[‘reg_price’])
But all errors 
Do any of those look close to you?
Might be missing something here, but this works for me:
"$"+self.item['my_name']
clone:
1 Like
Hm okay so I tried that like so:
"$"+self.item['reg_price']
but got the error
Error binding text of price_label to "$"+self.item['reg_price']:
cannot concatenate 'str' and 'int' objects
so I wrapped it in a str() function like so:
"$"+str(self.item['price'])
but now I’m back to the original error 
ValueError: invalid literal for int() with base 10: '$25'
It sounds like you have write-back enabled? So it’s not just displaying using the $, but then trying to convert back to an int later?
1 Like
Can you share a clone? But please consider what @jshaffstall says.
1 Like
Here’s the clone, just took the one you made @alcampopiano and changed the data binding to the number column in the data table.
https://anvil.works/build#clone:QF6WNDHIDZFXML5U=MUDJCBBW3KC64H6EVUW6VZ4Q
and @jshaffstall I don’t think I have write-back turned on
Thank you. Do you get an error with that clone? The str conversion works for me.
"$"+ str(self.item['my_num'])
1 Like
You have dependencies in that app which prevents me from running it.
Ah sorry about that! It’s just the custom sign up flow clone.
Here you go:
https://anvil.works/build#clone:QJZ3KIKPQMK76DBZ=HULRNDPRF2FVUVFRCJH5P25S
@chesney.l I would rather not get your full app working with its dependencies. Could you please strip out what you need to so that it works and demonstrates the issue?
Every thing looks fine if I use:
deal_percentage = int(self.deal_price.text.strip("$"))/int(self.price_label.text.strip("$"))
If this doesn’t help please explain clearly how the repeating panel items should look instead.
2 Likes
That’s perfect thank you so much! I’m not exactly sure how that solved the problem but it 100% did, thank you!
1 Like