PyQt4 - closing a dialog window, exec_() not working
===

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:

Dialog window initialised as such;

    def begin_grab(self):
        self.GrabIm=qtg.QDialog(self)
        self.GrabIm.ui=Ui_Dialog()
        self.GrabIm.ui.setupUi(self.GrabIm)
        self.GrabIm.show()

Dialog window;

    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_()

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. 

Any and all help would be appreciated. 