Q:

Returning value from custom Dialog in Python

I have a function called queryURI that opens a custom Dialog, this Dialog contains code to get input from the user. 
def queryURI(self,e):
    global outDir
    dlg = queryURIDlg()
    dlg.ShowModal()
    dlg.Destroy()
    self.ProgressBox.AppendText('Querying ' + [return value to go in here])

When 'OK' button is clicked it starts a function called retValue, it gets the text value from the text box, and assigns value depending on what radio button is checked. I then want to return these string values. I have tried EndModal(), but don't think I'm using it correctly.
def retValue(self,e):
    uriTxt = self.uriTxt.GetValue()
    if self.inj1.GetValue() == True:
        uriInj = ' --vertical'
    elif self.inj2.GetValue() == True:
        uriInj = self.inj2Txt.GetValue()
    uriTxt = uriTxt + uriInj
    uri = EndModal(uriTxt)
    self.Destroy()

How do I correctly return a value from a custom Dialog please?

A:

I would suggest to use the context manager "with" for the dialog, it will destroy it when the dialog is no longer used.  You need to get the value you are interested in from your dialog use after ShowModal returns. 
def queryURI(self,e):
    global outDir
    valueYouWant = ""
    with queryURIDlg() as dlg:
        dlg.ShowModal()
        valueYouWant = dlg.getYourValue()
    self.ProgressBox.AppendText('Querying ' + valueYouWant)

