title: Python - Tkinter: Window class
body: <p>How can you create a window in tkinter with a class?</p>
  
  <p>i know <code>root = Tk()</code> is the standard way to do it, but if i want to make a class that create a "window" in python that i can add buttons to later on who is that done?</p>
  
  <p>I get this error from the code down below:</p>
  
  <pre><code>Traceback (most recent call last):
    File "C:/Users/euc/PycharmProjects/Skole/Shortcut/Gui2.py", line 26, in &lt;module&gt;
      b = Create_button(a)
    File "C:/Users/euc/PycharmProjects/Skole/Shortcut/Gui2.py", line 18, in __init__
      self.button = Button(window, text=text)
    File "C:\Python34\lib\tkinter\__init__.py", line 2161, in __init__
      Widget.__init__(self, master, 'button', cnf, kw)
    File "C:\Python34\lib\tkinter\__init__.py", line 2084, in __init__
      BaseWidget._setup(self, master, cnf)
    File "C:\Python34\lib\tkinter\__init__.py", line 2062, in _setup
      self.tk = master.tk
  AttributeError: 'Create_window' object has no attribute 'tk'
  </code></pre>
  
  <p>My code:</p>
  
  <pre><code>from tkinter import *
  
  class Create_window(): #Create a window
      win = Tk()
      def __init__(self):
          self = Tk()
          self.title("This is title Name")
  
  class Create_button: # Create a button within the window
      text = "None"
      button_width = 15
      button_height = 10
  
      def __init__(self, window, text="null"):
          if text == "null": #Set text to none if none parameter is passed
              text = self.text
  
          self.button = Button(window, text=text)
          self.button.grid(row=0, column=0)
  
  
  
  a = Create_window()  # Create window
  b = Create_button(a) # Create button within Window
  
  a.mainloop()
  </code></pre>