title: Questions on using ttk.Style()?
body: <p>To make available an instance of the ttk.Style() class, it was illustrated  in this <a href="http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/ttk-theme-layer.html" rel="noreferrer">tkinter guide</a> that the syntax is:</p>
  
  <pre><code>import ttk
  s=ttk.Style()
  </code></pre>
  
  <p>When typing these command in IDLE, I noticed that ttk.Style() actually has a predefined argument, i.e.</p>
  
  <pre><code>s=ttk.Style(master=None)
  </code></pre>
  
  <p>I have written the following test script:</p>
  
  <pre><code>import tkinter as tk
  import tkinter.ttk as ttk
  
  
  class App(ttk.Frame):
  
      def __init__(self, parent):
          ttk.Frame.__init__(self, parent, style='App.TFrame', relief=tk.SUNKEN,
                             border=10)
          self.parent = parent
          self.__createStyle()
          self.__createWidgets()
  
      def __createStyle(self):
          self.s = ttk.Style()
          self.s.configure('.', background='orange', border=100)
          self.s.configure('App.TFrame', background='yellow')
          self.s.configure('Btn.TButton', background='light blue', border=10)
  
      def __createWidgets(self):
          self._label = ttk.Label(self.parent, text='Label packed in root.')
          self._label.pack()
          self._btn = ttk.Button(self, style='Btn.TButton', command=self.__click,
              text='Button packed inside self or class App, which is a ttk.Frame')
          self._btn.pack()
  
      def __click(self):
          return print('Left Button Clicked!')
  
  
  
  class myWidget(ttk.Frame):
  
      def __init__(self, parent):
          ttk.Frame.__init__(self, parent, style='my.TFrame', relief=tk.GROOVE,
                             border=10)
          self.parent = parent
          self.__createStyle()
          self.__createWidgets()
  
      def __createStyle(self):
          self.s = ttk.Style()
          self.s.configure('my.TFrame', background='purple')
          self.s.configure('my.TLabel', background='pink', border=10)
          self.s.configure('my.TEntry', foreground='red', border=10)
  
      def __createWidgets(self):
          self._label = ttk.Label(self, style='my.TLabel',
              text='myWidget Label packed in self or class myWidget, which is a ttk.Frame.')
  
          self._label.pack()
          self._entry = ttk.Entry(self, style='my.TEntry')
          self._entry.pack()
  
  
  
  if __name__ == "__main__":
      root = tk.Tk()
      root.title('Test Style')
      root.geometry('500x150')
      a = App(root)
      a.pack(fill='both', expand=1)
      b = myWidget(a)
      b.pack()
  
      root.mainloop()
  </code></pre>
  
  <p><strong>Question 1:</strong> When do I need to declare the <code>master</code> arguement in <code>ttk.Style()</code>? E.g. in the above script, if I write <code>self.s = ttk.Style()</code> and <code>self.s = ttk.Style(master=self.parent)</code> in <code>class myWidget</code>, I get the same result (see Fig1).</p>
  
  <p><strong>Question 2:</strong> Is there a need to prefix <code>s=ttk.Style()</code> with <code>self</code>? I get the same result as shown in Fig1 with and without the <code>self</code> prefix.</p>
  
  <p><strong>Question 3:</strong> If I rename <code>'my.TFrame'</code> in class myWidget as <code>'App.TFrame'</code>(this name was used in <code>class App</code>), the background colour of the <code>class App</code> changed to purple color too (same color as <code>class myWidget</code>. Why did this happened given that variable name in different classes are unique?</p>
  
  <p><strong>Question 4:</strong> The names <code>'App.TFrame'</code> and <code>'my.TFrame'</code> were called before it was declared. Why did python or tkinter not complain or give an  error but allowed the script to execute? </p>
  
  <p><a href="https://i.stack.imgur.com/PmYYB.png" rel="noreferrer"><img src="https://i.stack.imgur.com/PmYYB.png" alt="Fig1"></a></p>
  
  <p><strong>Figure 1</strong></p>
  
  <p><a href="https://i.stack.imgur.com/uxXYu.png" rel="noreferrer"><img src="https://i.stack.imgur.com/uxXYu.png" alt="Fig2"></a></p>
  
  <p><strong>Figure 2</strong></p>