title: How to access variables from one class to another class in PyQt4?
body: <p>I want to get a string from the main window to use in a window triggered with a click. I know how to do it by putting all statements into a single class, but now I'm trying to do the same thing with one class per window. Here is the code:</p>
  
  <pre><code>import sys
  from PyQt4 import QtGui
  
  class Window(QtGui.QWidget):
      def __init__(self, parent=None):
          super().__init__()
          self.initUI()
  
      def initUI(self):
          self.value = QtGui.QLineEdit('23')
          self.button = QtGui.QPushButton('Open Dialog')
          self.button.clicked.connect(self.openDialog)
  
          vbox = QtGui.QVBoxLayout()
          vbox.addWidget(self.value)
          vbox.addWidget(self.button)
          self.setLayout(vbox)
  
      def openDialog(self):
          self.entry = self.value.text()
          print(self.entry)
          Dialog().exec_()
  
  class Dialog(QtGui.QDialog):
      def __init__(self, parent=Window):
          super().__init__()
  
          win = Window()
          self.text = win.entry
          self.label = QtGui.QLabel(self.text)
  
          hbox = QtGui.QHBoxLayout()
          hbox.addWidget(self.label)
          self.setLayout(hbox)
  
  
  def main():
      app = QtGui.QApplication(sys.argv)
      w = Window()
      w.show()
      sys.exit(app.exec_())
  
  if __name__ == '__main__':
      main()
  </code></pre>
  
  <p>But I'm getting the error "<em>AttributeError: 'Window' object has no attribute 'entry'</em>" and I don't know any other way to try fix it. Can someone help me with it?</p>