Thanks for this wonderful project. I am facing an issue with the RadioButton. I have four radio buttons defined and all are mapped to the single variable "trdFlavor1". How can I get the StringVar value for the variable instead of IntVar. (See attached screenshot). Right now I am manually modifying the generated python file to say
self.trdFlavor1 = tk.StringVar()
I tried setting textVar to trdFlavor1 but it creates multiple lines like this for each radiobutton.
Many years ago, the Radiobuttons were able to take a StringVar or an IntVar depending on the value given to the widget. However, recently we went with using an IntVar internally, in an attempt to keep confusion out of the coding process. Can you image if you had your four TRadiobuttons three with StringVars and one with an IntVar, but pointed to the same variable? It would get fairly ugly.
So, you are stuck with IntVars for the value attribute.
However, it isn't all bad news. Set the Value to 1 for the first, increment the value for each of the others. You can keep the Variable the same for all (defaults to "selectbutton" and use the same command callback for all four.
Then the callback can handle thing easily with an if|elif tree...
Hello,
Thanks for this wonderful project. I am facing an issue with the RadioButton. I have four radio buttons defined and all are mapped to the single variable "trdFlavor1". How can I get the StringVar value for the variable instead of IntVar. (See attached screenshot). Right now I am manually modifying the generated python file to say
self.trdFlavor1 = tk.StringVar()
I tried setting textVar to trdFlavor1 but it creates multiple lines like this for each radiobutton.
Am I doing something wrong here?
Thanks in anticipation!
Have a great day!
Many years ago, the Radiobuttons were able to take a StringVar or an IntVar depending on the value given to the widget. However, recently we went with using an IntVar internally, in an attempt to keep confusion out of the coding process. Can you image if you had your four TRadiobuttons three with StringVars and one with an IntVar, but pointed to the same variable? It would get fairly ugly.
So, you are stuck with IntVars for the value attribute.
However, it isn't all bad news. Set the Value to 1 for the first, increment the value for each of the others. You can keep the Variable the same for all (defaults to "selectbutton" and use the same command callback for all four.
Then the callback can handle thing easily with an if|elif tree...
I hope this helps.
Greg
Makes sense. Thanks for the clarification!