Can't change a variable using a function Python
<p>I'm playing with functions in Python and i though I could do the JOptionPane from Java using the Tkinter... I'm running Python 3.x but I'm having a little trouble</p>

<pre><code>from tkinter import *

def showMessageDialog(text):
    text = text
    janela = Tk()
    janela.geometry("400x100")
    janela["bg"] = "grey"
    janela.title(" ")
    lb = Label(janela, text=str(text))
    lb.place(x=200,y=50)
    janela.mainloop()


def showInputDialog(text):
    x = " "
    def botaoClicado():
            x = ed.get()
            janela.destroy()
            return x

    text = str(text)
    janela = Tk()
    janela.geometry("400x100")
    janela["bg"] = "grey"
    janela.title(" ")

    lb = Label(janela, text=str(text))
    lb.place(x=120,y=10)

    bt = Button(janela, width=10, text="Ok", command=botaoClicado)
    bt.place(x=120,y=65)

    ed = Entry(janela)
    ed.place(x=120,y=35)

    janela.mainloop()

    return x

x=0
x = showInputDialog("Insira seu nome!")
</code></pre>

<p>I'm sorry it is in portuguese, but I think it's possible for you guys to help me. My problem is the following:</p>

<p>When I click the button, the Entry don't get returned to the other function. I apologize but i don't know how I can explain better.</p>

<p>The call to mainloop does not stop until all tkinter Windows close. Therefore your function hangs when you call <code>janela.mainloop()</code>. Instead, it's best practice to call mainloop in the main thread (at the bottom of your script), and use callbacks to process input. For example, once your message dialog box gets an answer, it can call a function to process the answer.</p>

python function tkinter