Python Forum

Full Version: passing str from Callfunction to another Callfunction
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am trying to pass the str/path from a Callfunction to another Callfunction. First call function is trigger by a click button and keep the path with G , and I cant find a way to pass this str/path to another Callfunction. below is my code and try to pass it to function RUN. possible keep the str G in global , so that all other Callfunction can using same info?

inputformat = [("op1","op1"),("op2","op2"),("op3","op3")]
V = StringVar()
for text, mode in inputformat:
        b = Radiobutton(main, text = text, variable = V, value = mode)
        b.grid(column=4 )
def OpenFolder():     
        main1.filename = filedialog.askdirectory()
        G= os.path.normpath(main.filename)
        TryPassG = G
def RUN():
        optVal = V.get()
        if optVal == "op1": op1F()
        elif optVal == "op2": op2F()
        elif optVal == "op3": op3F()
Button(master1, text ="OpenFolder", command = OpenFolder,width=20).grid(column = 3,row=0,sticky='W')
Button(master1, text ="RUN", command = RUN,width=20).grid(column = 3,row=2,sticky='W')

i think i found the answer>> "global G" in function :)