Python and Tkinter root naming
Question: I often see a GUI using root.mainloop() at the end. Near the top sometimes
they put: root=tk.TK() and sometimes they just put: root=Tk()

## Do these two statements do something different? (examples below)

    
    
    from Tkinter import *
    class App:
      def __init__(self, master):
        frame = Frame(master)
        frame.pack()
        self.button = Button(frame, 
                             text="QUIT", fg="red",
                             command=frame.quit)
        self.button.pack(side=LEFT)
        self.slogan = Button(frame,
                             text="Hello",
                             command=self.write_slogan)
        self.slogan.pack(side=LEFT)
      def write_slogan(self):
        print "Tkinter is easy to use!"
    
    root = Tk()
    app = App(root)
    root.mainloop()
    

* * *
    
    
    import Tkinter as tk
    
    counter = 0 
    def counter_label(label):
      counter = 0
      def count():
        global counter
        counter += 1
        label.config(text=str(counter))
        label.after(1000, count)
      count()
    
    root = tk.Tk()
    root.title("Counting Seconds")
    label = tk.Label(root, fg="dark green")
    label.pack()
    counter_label(label)
    button = tk.Button(root, text='Stop', width=25, command=root.destroy)
    button.pack()
    root.mainloop()
    

* * *


Answer: The difference is in the import statements. After `from Tkinter import *`, all
of the names from Tkinter are directly incorporated into your namespace; in
fact, you can't refer to `Tkinter` itself because that name wasn't imported.
In contrast `import Tkinter as tk` ONLY imports `Tkinter` (under the shorted
alias `tk`), and all further references to names from the Tkinter module have
to be prefixed with that name.

