title: Passing values between classes for tkinter, python
body: <p>I am trying to get my application to take the string that the user chooses from a listbox and use it in other parts of my code. Initially I am just trying to print the value once the user exits the app. My code looks like the following:</p>
  <pre><code>class Arrivals(tk.Frame):
  
      def showSelected(self):
          self.item = self.listbox.get(listbox.curselection())
  
  
      def __init__(self, parent, controller):
          tk.Frame.__init__(self, parent)
          label = tk.Label(self, text=&quot;arrivals&quot;, font=LARGE_FONT)
          label.pack(pady=10, padx=10)
          listbox = tk.Listbox(self, selectmode=tk.SINGLE)
          listbox.config(width=0)
          counter = 0
          
  
          for i in listan_2:
              listbox.insert(counter, i[2] + ' ' + i[0] + ' ' + i[1])
  
          listbox.pack()
  
  
          self.button = ttk.Button(self, text='Choose arrival',
                              command=lambda: [self.showSelected, controller.show_frame(registrering)]).pack(pady=20)
          button1 = ttk.Button(self, text=&quot;Back to home&quot;, command=lambda:[controller.show_frame(StartPage),
                                                                          showSelected()])
          button1.pack()
  
          button2 = ttk.Button(self, text=&quot;Page Two&quot;, command=lambda:controller.show_frame(PageTwo))
          button2.pack()
  </code></pre>
  <p>at the very end of my code, I am trying to print out the value using</p>
  <pre><code>arrivals.item
  </code></pre>
  <p>and I end up with the following error message:</p>
  <pre><code>AttributeError: type object 'arrivals' has no attribute 'item'
  </code></pre>
  <p>To recap, I want the string 'item' to be accessible to other classes.
  I have searched for an answer but none presented have been able to solve this. I do not want to use global variables.</p>