title: Using a returned variable from one file in another in python
body: <p>I am using kivy to create some basic GUI for a project and have separated that into another .py file from the other code related to the program. Here is GUI.py:</p>
  <pre><code>class MyGrid(GridLayout):
      def __init__(self, **kwargs):
          super(MyGrid, self).__init__(**kwargs)
          self.cols = 1
          self.inside = GridLayout()
          self.inside.rows = 3
  
          self.inside.add_widget(Label(text = &quot;Enter a name: &quot;))
  
          self.name =  TextInput(multiline = False)
          self.inside.add_widget(self.name)
  
          self.add_widget(self.inside)
  
          self.go = Button(text = &quot;Go!&quot;, font_size = 38)
          self.add_widget(self.go)
          self.go.bind(on_press = self.pressed)
  
      def pressed(self, instance):
          track_name = self.name.text
          return track_name
  
  class GUI(App):
      def build(self):
          return MyGrid()
  
  GUI().run()
  </code></pre>
  <p>I want to use the track_name variable in project.py but don't know how to access it. Here is project.py:</p>
  <pre><code>import GUI
  track_name = GUI.pressed()
  print(track_name)
  </code></pre>
  <p>The error is:</p>
  <pre><code>Traceback (most recent call last):
     File &quot;D:\Python Projekti\xxxx\project.py&quot;, line 8, in &lt;module&gt;
       track_name = GUI.pressed()
   AttributeError: module 'GUI' has no attribute 'pressed'
  </code></pre>
  <p>What should I change?</p>