title: Getting a second window pass a variable to the main ui and close
body: <p>I'm trying to get a variable selected from the list to be sent back to the main window and then close the second window when the ok button is pressed. Currently the second window will not close. Any help will be greatly appreciated.</p>
  
  <p>Code:</p>
  
  <pre><code>class select_variable_window(QDialog):
      def __init__(self, list, parent=None):
          super().__init__(parent)
          self.label = QtWidgets.QLabel(self)
          self.label.setGeometry(QtCore.QRect(20, 10, 251, 16))
          self.label.setObjectName("label")
          self.label=QLabel("Select Variable for Scatterplot", self)
  
          self.dialogbutton = QtWidgets.QDialogButtonBox(self)
          self.dialogbutton.setGeometry(QtCore.QRect(120, 260, 161, 32))
          self.dialogbutton.setOrientation(QtCore.Qt.Horizontal)
          self.dialogbutton.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
          self.dialogbutton.setObjectName("dialogbutton")
  
          self.variablelist = QtWidgets.QListWidget(self)
          self.variablelist.setGeometry(QtCore.QRect(10, 30, 391, 221))
          self.variablelist.setObjectName("variablelist")
          self.variablelist.setSelectionMode(QAbstractItemView.SingleSelection)
          self.variablelist.addItems(list)
  
          self.dialogbutton.accepted.connect(self.accept)
          self.dialogbutton.rejected.connect(self.reject)
          QtCore.QMetaObject.connectSlotsByName(self)
  
      def accept(self):
          self.scattervariable=[item.text() for item in self.variablelist.selectedItems()]
          print(self.scattervariable)
          self.close()# wont close
          return
  
      def reject(self):
          self.close()#wont close
          return
  </code></pre>