title: Questions about object has no attribute(Python)
body: <p>When I try to change my teacher's code to create a new dialog, the shell always shows that <code>NameDialog object has no attribute _column_enter</code>.  </p>
  
  <p>However, my teacher's code can work so I am wondering, what's the difference to make my code can not work:</p>
  
  <pre><code>import tkinter
  
  Font=('Helvetica', 14)
  
  
  class User_design:
      def __init__(self):
          self._root_window=tkinter.Tk()
          start_button=tkinter.Button(
              master=self._root_window, text='click there to start.',
              font=Font, command=self._get_start)
          start_button.grid(
              row = 0, column = 0, padx = 10, pady = 10,
              sticky = tkinter.S)
  
  
  
          self._greeting_text = tkinter.StringVar()
          self._greeting_text.set('Not begin')
  
          greeting_label = tkinter.Label(
              master = self._root_window, textvariable = self._greeting_text,
              font =  Font)
  
          greeting_label.grid(
              row = 1, column = 0, padx = 10, pady = 10,
              sticky = tkinter.N)
  
          self._root_window.rowconfigure(0, weight = 1)
          self._root_window.rowconfigure(1, weight = 1)
          self._root_window.columnconfigure(0, weight = 1)
  
  
  
  
  
      def start(self) -&gt; None:
          self._root_window.mainloop()
  
      def _get_start(self):
          dialog = NameDialog()
          dialog.show()
  
          if dialog.was_ok_clicked():
              column=dialog.get_column()
              row=dialog.get_row()
              turn=dialog.get_turn()
              top_left=dialog.get_top_left()
              win_method=dialog.get_win_method()
  
  
  class NameDialog:
      def __init__(self):
          self._dialog_window = tkinter.Toplevel()
  
          #column_label
          column_label=tkinter.Label(
              master=self._dialog_window, text='How many columns?',
              font=Font)
          column_label.grid(
              row=0, column=0, padx=10,pady=10, sticky=tkinter.W)
          self._column_entry = tkinter.Entry(
              master = self._dialog_window, width = 20, font = Font)
          self._column_enter.grid(
              row=0, column=1, padx=10,pady=10, sticky=tkinter.W)
  
  
  
          #row_input
          row_input=tkinter.Label(
              master=self._dialog_window, text='How many rows?',
              font=Font)
          row_input.grid(
              row=1, column=0, padx=10,pady=10, sticky=tkinter.W)
          self._row_entry = tkinter.Entry(
              master = self._dialog_window, width = 20, font = Font)
          self._row_enter.grid(
              row=1, column=1, padx=10,pady=10, sticky=tkinter.W)
  
          #turn_input
          turn_input=tkinter.Label(
              master=self._dialog_window, text='Which color move first?',
              font=Font)
          turn_input.grid(
              row=2, column=0, padx=10,pady=10, sticky=tkinter.W)
          self._turn_entry = tkinter.Entry(
              master = self._dialog_window, width = 20, font = Font)
          self._turn_enter.grid(
              row=2, column=1, padx=10,pady=10, sticky=tkinter.W)
  
          #top_left_input
          top_left_input=tkinter.Label(
              master=self._dialog_window, text='Which color on top left?',
              font=Font)
          top_left_input.grid(
              row=3, column=0, padx=10,pady=10, sticky=tkinter.W)
          self._top_left_entry = tkinter.Entry(
              master = self._dialog_window, width = 20, font = Font)
          self._top_left_enter.grid(
              row=3, column=1, padx=10,pady=10, sticky=tkinter.W)
  
          #win_menthod_input
          win_method_input=tkinter.Label(
              master=self._dialog_window, text='win method?',
              font=Font)
          win_method_input.grid(
              row=4, column=0, padx=10,pady=10, sticky=tkinter.W)
          self._win_method_entry = tkinter.Entry(
              master = self._dialog_window, width = 20, font = Font)
          self._win_method_enter.grid(
              row=4, column=1, padx=10,pady=10, sticky=tkinter.W)
  
  
  
          button_frame = tkinter.Frame(master = self._dialog_window)
          button_frame.grid(
              row = 5, column = 0, columnspan = 2, padx = 10, pady = 10,
              sticky = tkinter.E + tkinter.S)
          ok_button = tkinter.Button(
              master = button_frame, text = 'OK', font = Font,
              command = self._on_ok_button)
          ok_button.grid(row = 0, column = 0, padx = 10, pady = 10)
          cancel_button = tkinter.Button(
              master = button_frame, text = 'Cancel', font = Font,
              command = self._on_cancel_button)
          cancel_button.grid(row = 0, column = 1, padx = 10, pady = 10)
  
  
          self._dialog_window.rowconfigure(5, weight = 1)
          self._dialog_window.columnconfigure(1, weight = 1)
  
  
          self._ok_clicked = False
          self._column = ''
          self._row = ''
          self._turn=''
          self._top_left=''
          self._win_method=''
  
  
      def show(self):
          self._dialog_window.grab_set()
          self._dialog_window.wait_window()
  
      def was_ok_clicked(self) -&gt; bool:
          return self._ok_clicked
  
  
      def get_column(self) -&gt; str:
          return self._column
  
  
      def get_row(self) -&gt; str:
          return self._row
  
      def get_turn(self)-&gt;str:
          return self._turn
  
      def get_top_left(self)-&gt;str:
          return self._top_left
  
      def get_win_method(self)-&gt;str:
          return self._win_method
  
      def _on_ok_button(self) -&gt; None:
          self._ok_clicked = True
          self._column = self._column_entry.get()
          self._row = self._row_entry.get()
          self._turn = self._turn_entry.get()
          self._top_left = self._top_left_entry.get()
          self._win_menthod = self._win_method_entry.get()
  
          self._dialog_window.destroy()
  
  
      def _on_cancel_button(self) -&gt; None:
          self._dialog_window.destroy()
  
  
  
  
  
  if __name__ == '__main__':
      User_design().start()
  </code></pre>