The first argument for python Tkinter
Question: I am using Tkinter with python 2.7 and am curious about why the following code
snippet would work:

    
    
    import Tkinter as tk
    import ttk
    
    class Application(ttk.Frame):
    
        def __init__(self, master=None):
            ttk.Frame.__init__(self, master) # This is where my question is
            self.grid()
            return
    
    if __name__ == '__main__':
        root = tk.Tk()
        app = Application(root)
        root.mainloop()
    

1) The `ttk.Frame.__init__` takes one argument, which is the `master`. But now
the first argument is an instance inherited from it, and the second is
`master`. How did this work?

2) I noticed that the `ttk.Frame` class also have a function called
`mainloop`. How is this different from `root.mainloop()`?

Thanks!


Answer: 1) `ttk.Frame.__init__()` in method `Application.__init__()` is used to
initialize base class `ttk.Frame`, the explaination doc is
[here](https://docs.python.org/2/reference/datamodel.html#object.__init__).

2) `mainloop()` in `ttk.Frame` and `root.mainloop()` is equal, please look at
[this](http://python.6.x6.nabble.com/the-difference-between-mainloop-and-app-
mainloop-and-root-mainloop-td1975563.html).

