Python Forum
[Tkinter] Not able to use the output from one function into another function
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Not able to use the output from one function into another function
#1
Hi Team,

print("YOU_SELECTED"+Region)line in below code is not coming. Please help me with this




from tkinter import *
def drop_dwn():
    OPTIONS = ["DEV","LB","ST"] #etc

    master = Tk()

    variable = StringVar(master)
    variable.set("Select_the_Regions") # default value

    w = OptionMenu(master, variable, *OPTIONS)
    w.pack()

    def ok():
        global Region
        print ("value is:" + variable.get())
        Region=variable.get()
        master.destroy()

    button = Button(master, text="OK", command=ok)
    button.pack()

    mainloop()
def Run_in_soap():
    drop_dwn()
    print("YOU_SELECTED"+Region)  
  
# create a tkinter window 
root = Tk()               
  
# Open window having dimension 100x100 
root.geometry('100x100')  
  
# Create a Button 
btn = Button(root, text = 'Click me !', bd = '5', 
                          command = Run_in_soap)  
  
# Set the position of button on the top of window.    
btn.pack(side = 'top')     
  
root.mainloop()
Reply
#2
Where do you want to show this line "print("YOU_SELECTED"+Region" ?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  send function output from one py file to another (OOP) lunacy90 15 2,295 Aug-26-2023, 02:42 PM
Last Post: deanhystad
  Stop import from executing function, but allow the function to execute from tk btn. MrBitPythoner 4 2,624 Dec-08-2020, 10:00 PM
Last Post: MrBitPythoner
  Call local variable of previous function from another function with Python3 & tkinter Hannibal 5 4,357 Oct-12-2020, 09:16 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020