title: PyQt4 - closing a dialog window, exec_() not working
body: <p>Trying to build a user interface using PyQt4. Got a dialog window that pops up, and I want it to do something then close, when 'Ok' is pressed. Unfortunately, I can't seem to get it working - tried all sorts of combinations of Dialog.exec_(), Dialog.close(), self.exec_(), self.close(), emitting an 'accepted' signal to Dialog.accept, etc. So far, nothing has worked, and I'm not quite sure why. Here's the code for it:</p>
  
  <p>Dialog window initialised as such;</p>
  
  <pre><code>def begin_grab(self):
      self.GrabIm=qtg.QDialog(self)
      self.GrabIm.ui=Ui_Dialog()
      self.GrabIm.ui.setupUi(self.GrabIm)
      self.GrabIm.show()
  </code></pre>
  
  <p>Dialog window;</p>
  
  <pre><code>class Ui_Dialog(object):
  
      def setupUi(self, Dialog):
          Dialog.setObjectName(_fromUtf8("Dialog"))
          ...
          QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), self.accept)
          QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), Dialog.reject)
          QtCore.QMetaObject.connectSlotsByName(Dialog)
  
      def accept(self):
          if self.radioButton.isChecked()==True: #assume it is true
              #Call continuous grabber
              print "Grabbing continuously"
              Dialog.exec_() #Close it here
          else:
              #Call trigger server
              print "Grabbing triggered"
              self.exec_()
  </code></pre>
  
  <p>The main thing that keeps happening is either a message saying 'Dialog' is an unknown variable, in the accept() function, or if I use self.exec_() or similar it says exec_() is not a known attribute. If I try doing accept(self, Dialog), and put self.accept(Dialog) in the connect statement, it also crashes. </p>
  
  <p>Any and all help would be appreciated. </p>