tkinter dialog window not working inside while loop?
<p>Apparently, tkinter doesn't allow you to use a while loop as it already runs its own loop so I need help on making my code work with the while loop. I believe it has something to do with "mainloop()" but I'm not sure how to use it.</p>

<p>Code below (works without loop):</p>

<pre><code>while (1):
    choice = input("Choose 1 to open dialog, 2 to end the program.\n")
    if choice == "1":
        from tkinter import *
        root = Tk()
        root.withdraw()
        fileName = filedialog.askopenfilename(filetypes = ([("Text file","*.txt")]),title='Please select a text file')
        file = open(fileName)
        sentence = file.read()
        file.close()

    elif choice == "2":
        break
</code></pre>