0

Im a bit stuck!

Im new to python coding and this is my second project and Ive hit a wall.

basically Ive made a GUI with 12 radio buttons in 3 sets, (3,3,6) plus an "execute" button, plus various other scripts to execute certain GPIO outputs.

what i want is to be able to select 3 options from the GUI and when i hit the "execute" button for it to run the appropriate .py file

i have got it working to return a value from the 3 variables like so:

def sel():
    X = dr1.get()
    Y = dr2.get()
    Z = dr3.get()
    return X+Y+Z

this gives me a value for example of "appleorangebanana" or with different radio buttons selected a value of "applegrapebanana"

all possible returned values have a corresponding .py file saved with its own script.

where im getting stuck is using the returned value to run the right file when i hit the "execute" button

thanks for any help

Mike.B
  • 1
  • 2
  • 1
    Possible duplicate of [What is the best way to call a Python script from another Python script?](https://stackoverflow.com/questions/1186789/what-is-the-best-way-to-call-a-python-script-from-another-python-script) – mkrieger1 May 29 '18 at 11:16
  • 1
    any script can be packaged in a function. import each function from the appropriate .py module, figure out which one to run and run it. – e.s. May 29 '18 at 11:22
  • I looked at that post first but need the “call file” function to open up 1 of about 30 files and it be different each time. I can’t seem to get the function to open the returned value as what ever I try I just get (xxx) is not defined, if I add import (filename) the “execute” button it works perfectly but need the (filename) to be the returned value from the radio buttons – Mike.B May 29 '18 at 11:27
  • Are you asking how to make your function return `'appleorangebanana.py'` instead of `'appleorangebanana'`? – mkrieger1 May 29 '18 at 12:43
  • Possibly. The radio buttons can return 54 possible combinations and I have 54 separate scripts written for each one and saved with the same names as the possible returned value. For example- 111,112,113,121,122,123 and so on. (Values and files are words not numbers so I can identify then easily but they’re long so I’m not writing them here). When I hit the last button which has ‘command =‘ attached to it i need the main script to run the chosen file. – Mike.B May 29 '18 at 14:10

0 Answers0