Can someone help me make the transition to a new window using Tkinter in Python?
<p>Im very new and am interested in working with windows and Tkinter. please be gentle.</p>

<p>here is my code that is supposed to go to a new window then open an image in that new window. However, instead of putting the image in the new window it puts it in the first window.</p>

<p>I think this has something to do with toplevel but i cant seem to make that work right.    </p>

<pre><code>import os
from PIL import Image
from PIL import ImageTk
from Tkinter import Tk
import os

class Application(Frame):
    """ A GUI application with three buttons. """

    def __init__(self, master):
        """ Initialize the frame"""
        Frame.__init__(self,master)
        self.grid()
        self.create_widgets()



    def create_widgets(self):
        """ Create button, text and entry widgets"""
        self.instruction = Label(self, text = "First off what is your name?")
        self.instruction.grid(row=0, column =0, columnspan=2, sticky=W)

        #self.first = first

        self.name = Entry(self)
        self.name.grid(row=1, column =1, sticky=W)

        self.submit_button = Button(self, text ="Submitsss", command = self.reveal)
        self.submit_button.grid(row = 2, column = 0, sticky =W)

        self.text = Text(self, width =35, height = 5, wrap = WORD)
        self.text.grid(row=3, column = 0, columnspan =2, sticky = W)

        self.ok_button = Button(self, text = "Next", command = self.go_to_2)
        self.ok_button.grid(row = 2, column = 0, sticky = E)

    def reveal(self):
        """Display message based on the name typed in"""
        content = self.name.get()

        message = "Hello %s" %(content)

        self.text.insert(0.0, message)

    def go_to_2(self):
        self.destroy()
        #root = Tk()
        #self.newApplication = tk.Toplevel(self.master)
        #self.app3 = Application2(self.newApplication)
        root.title("game")
        root.geometry("600x480")

        #root = Tk()
        #app2=Application2(root)

        self.newWindow = Tk.Toplevel()
        self.app = Application2(self.newWindow)


class Application2(Frame):
    """ A GUI application with three buttons. """

    def __init__(self, master):
        """ Initialize the frame"""
        Frame.__init__(self,master)
        self.grid()
        self.create_widgets()
        #master.panel()
        master.title("a")
        #self.root.mainloop()
        master.img = ImageTk.PhotoImage(Image.open("C:\Users\david\Pictures\sdf.jpg"))
        master.panel = Label(root, image = master.img)
        master.panel.pack()
    def create_widgets(self):


        self.submit_button = Button(self, text ="Submit")
        self.submit_button.grid(row = 2, column = 0, sticky =W)
        self.name = Entry(self)
        self.name.grid(row=1, column =1, sticky=W)
        self.ok_button = Button(self, text = "Next", command = self.go_to_3)
        self.ok_button.grid(row = 2, column = 0, sticky = E)
    def go_to_3(self):
        root = Tk()

        app2=Application3(root)
    #def create_picture(self):




class Application3(Frame):
    """ A GUI application with three buttons. """

    def __init__(self, master):
        """ Initialize the frame"""
        Frame.__init__(self,master)
        self.grid()
        self.create_widgets()
    def create_widgets(self):
        self.button = Button(self, text = "ass")
        root.mainloop()

root = Tk()
root.title("game")
root.geometry("600x480")




app = Application(root)
root.mainloop() 

#app2= Application2(root)

#if __name__ == '__main__':
       # main()
</code></pre>

<p>Try this code:</p>

<pre><code>import tkinter as tk

class MainWindow(tk.Frame):
    counter = 0
    def __init__(self, *args, **kwargs):
        tk.Frame.__init__(self, *args, **kwargs)
        self.button = tk.Button(self, text="Create new window", 
                                command=self.create_window)
        self.button.pack(side="top")

    def create_window(self):
        self.counter += 1
        t = tk.Toplevel(self)
        t.wm_title("Window #%s" % self.counter)
        l = tk.Label(t, text="This is window #%s" % self.counter)
        l.pack(side="top", fill="both", expand=True, padx=100, pady=100)

if __name__ == "__main__":
    root = tk.Tk()
    main = MainWindow(root)
    main.pack(side="top", fill="both", expand=True)
    root.mainloop()
</code></pre>

<p>This will make a window and you can push a button to pop up a new window. There is already a label on that window as an example.</p>

python windows tkinter