Tkinter messes up entire script!!! omg

UPDATE: It seems that all the functions that are called after Display() are only halted untill after i close the window that is created with the Display(). How can I get them to execute regardless whether the gui is up or not?

So i want to make my own GUI with Tkinter but im having an issue.

the idea of my script is as follows:

  1. launch my Tkinter window which i stored as the function “Display()”
  2. then have a simple loop that keeps printing “yay” after Display has been called

so in my main(), i simply have a global variable called “count”. And only when “count” == 0, it calls the Display() and then adds 1 to my count variable in order to mark the end Display() and the beginning of Print(“yay”)

however. as soon as Display() is called, it seems that the execution of print(“yay”) never gets executed. Its as if calling Display() puts a holt to everything else that comes after it.

here is the script. Whats going on here?

and please excuse the indenting. BlenderArtists messes it up as i paste it in here.

###########################################
import Tkinter as tk

Count = 0

def Display():
canvas = tk.Tk()
img = ImageTk.PhotoImage(Image.open(‘c:\users\me\desktop\galaxy.png’))
panel = tk.Label(canvas, image = img)
panel.pack(side = “bottom”, fill = “both”, expand = “yes”)
canvas.mainloop()

def main():
global Count
if Count == 0:
Display() #### whenever i call this function, it prevents everything else after it from executing
Count = Count + 1
while Count > 0:
print(“yay”)

main()

##################################################################

i understand that i need to use threading and it seems to work in idle. but when i run it with python it doesnt. what is a “main” thread and how do i set a thread as main