Skip to content
Advertisement

Python – Using Tkinter–saving radio button variables between scripts

I have a script that uses tkinter. I have created predefined radio buttons in this script. I am trying to call the script from a second script. When I run the original script the print out works fine. However, when I run it from the second script, the radio button var.get() variable don’t seem to be translating between scripts and the print out is not as expected. What am I doing wrong? Any help with this would be greatly appreciated!!

Ex. when I run from first script the print out is:

You’ve selected Arctic

You’ve selected Forest

You’ve selected Grassland

You’ve selected Mountain

when I run from the second scrip the print out is:

You’ve selected

You’ve selected

You’ve selected

You’ve selected

–the radio button selection is missing

Additional details: Both scripts are saved in the same folder. I have tried setting “selection” as a global variable.

To reproduce this error:

1.save as two separate python scripts (first script, second script) within the same folder.

  1. Run the first script, make a radio selection, and the print message will be as expected. ex “You’ve selected Arctic”

  2. Run the second script, select “create” in the menu. Select “Get Monsters”. Make a radio button selection. The print out will only be “You’ve selected” It does not include the biome

First Script:

JavaScript

Second Script:

JavaScript

Advertisement

Answer

change the way var.get works for this.. also, use lambda in the command and it works…

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement