Here is the code:
value = self.value.selected_value
if value==True:
print(f"Your Choice was: {value}")
self.checkbox_assigned.checked
else:
print(f"Your Choice was : {value}")
pass
The print statements, provide the correct True or False
Help. What am I missing???
It is really simple. Iâll just provide a clue here that the checked property of checkbox accepts boolean values (True/False).
The Docs on Checkbox might also help you in your case
Edit: I checked the app and realized that your problem was something else. So here is another hint for you - the values in the Dropdown items are strings, not booleans.
I am not sure what you will achieve by that. However, I will like to point out that eval() function can be used for getting the boolean value from the string.
Otherwise, you can âtellâ your program that the selected value is going to be a string and not boolean.
would it be better to actually create the component, rather than try to populate an existing UI element?, then if condition is true I can create a pre-selected box, like this?
MyCheckBox([checked=True, text="Trip is Assigned])
I have tried various of combining the ([checked=True]) with self.checkbox_assigned.checked
all combinations I have tried have resulted in bad syntax errrors.
Iâm on a cell now, I canât clone. But if I understand you need to assign a value to something.
I see in the snippet a line with self.checkbox_assigned.checked. This line is not executing a function nor is assigning a value to something.
Translating from python to English: self means âa formâ. self.checkbox_assigned means âa checkboxâ. self.checkbox_assigned.checked means âthe status of the checkboxâ. If you tell that to your app, the app does nothing.
I you instead tell your app âplease set the status of that check box to checkedâ, then the app knows what to do. That translates to python self.checkbox_assigned.checked = True
Hi Stefano, thank you for the reply. I did try that, but it wasnt checking the tick on the check box, I just tried it again exactly as you said and its not working.
I am going to try to create the component from code and see if that works, TBH its probably a better way to do it.