Jump to content

Solutions to iterating over a dynamic widget name


---
 Share

Recommended Posts

I am attempting to create an application where I dynamically generate number of checkboxes (the number of checkboxes depends on the number of unique items in a text file). After which the user is required to type in a value. If the value entered is equal to the name assigned to one of the checkboxes, then the checkbox will be checked off.

When I run this code, my dialog event handler does not understand that "fixtureDictionary['fixtureName_0']" must actually correspond to the value of 'T30' (as an example). Instead, it's explicitly looking for the variable named 'fixtureDictionary'.

I am still a bit new to Python, and I am perplexed as to how to fix this I have been reading that it is generally bad practice to have dynamically named variables, but unfortunately every checkbox in my script is required to have a unique name.

Is there anyway to pass the dialog."something".value a dynamic name? Or is there a different approach I should take?

image.png.8bbb6b28c67a7e59d29a02f393248722.png

Link to comment
Share on other sites

Can you give detail of your ultimate goal , maybe there is a different way round.  Dynamic variable handling should be avoided in my experience, just gets messy and its not really geared to handle it

When faced with issues that seemed to require this after research ive found dictionaries can be used quite well.

Link to comment
Share on other sites

 Share

×
×
  • Create New...