You can check it at:
https://KACHQFBO75Z7AF6U.anvilapp.net/L42M6UYTRZ5KJE5EA5KDX2YG
Point is that I have years and prices per each year. The user can select a year from DropDown.
I need to know what year user selected and the corresponding price per that year.
My initial idea was to have one data structure, that would have years and prices per each year.
That is why I started with
price_per_years = [
("2002", 1),
("2003", 2)
]
self.year_drop_down.items = price_per_years
This was working fine (years have been in dropdown), but the problem was I did not found a way how to get a year (first element of a tuple) as I said self.year_drop_down.text
return an empty string ‘’.
Currently suggested solutions are also not working.
I ended up with this:
price_per_years = [
("2002", '2002-1.4'),
("2003", '2003-2.2')
]
self.year_drop_down.items = price_per_years
# how I get price
str(self.year_drop_down.selected_value).split('-')[1]
# how I get year
str(self.year_drop_down.selected_value).split('-')[0]
I personally do not like it, because now I need to put a year in two places in the first element of the tuple and in the second, but it is working.
But if there is some better solution, that somebody has coded/tried in practice. please share it.