Can someone please help with an example for format_func ( function ) that is referenced in the API document for selectbox, radiobutton, multiselect etc and how to use it?
Would be nice if the API doc included an example for all the parameters for the methods.
In the Python code, I defined a lambda function that takes the input and adds the string “option” to the front of it. When the word selections are shown in the widget, it still returns the original value to the Python variable btn.
This can be useful in situations where you have keys that mean something, but are stored as integers in a process (common in databases). So you could pass a dict to the format_func that you define and do a key/value lookup, you could do a simple text transformation like I did, or anything else that is valid Python.
Would a format_func() be of any use in the scenario below? If not, how to do this?
DataFrame:
StoreID City State 1 Seattle Washington 2 Portland Oregon 3 Newark NewJersey 4 Phoenix Arizona 5 Chandler Arizona
I want the selectbox to display the options in the following format (Sorted by State then by City): Arizona - Chandler - 5 Arizona - Phoenix - 4 New Jersey - Newark -3 Oregon - Portland - 2 Seattle - Washington - 1
while the value for each option should be their corresponding StoreID.
While I get the displaying of options correctly, I can’t seem to associate the StoreID to the options. The value of the option I select is always the actual string being displayed like Seattle - Washington - 1 instead of just 1.