I'm attaching some code from qa-assistant that I believe implements the
behaviour you're asking for. Here's a summary:
- Create a dialog
- Loop until your dialog is filled out correctly
+ response = dialog.run() # Get input to your dialog
+ Check that all exit conditions are satisfied
* If so, exit the loop
* If not, loop again
- Destroy the dialogThe important part is to realize you need to call dialog.run() each time you want the user to fill out the dialog again. -Toshio
def add_item_cb(self, callbackMenu):
'''Adds a checklist entry to the checklist.
Sometimes there's something wrong with a product undergoing QA that
isn't on the checklist. Using this action allows you to add an entry
to the checklist you are currently filling out.
'''
# Dialog to prompt the user for the information
newItemDialog = gtk.Dialog('New checklist item',
qaapp.app.ReviewerWindow, 0, ('Add item', gtk.RESPONSE_OK,
gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
newItemDialog.set_default_response(gtk.RESPONSE_OK)
table = gtk.Table(3, 2, False)
table.attach(gtk.Label('Summary:'), 0,1, 0,1)
table.attach(gtk.Label('Initial Resolution:'), 0,1, 1,2)
table.attach(gtk.Label('Output:'), 0,1, 2,3)
summaryEntry = gtk.Entry()
resEntry = gtk.combo_box_new_text()
resList = ('Pass', 'Fail', 'Non-Blocker')
outputList = {}
for res in resList:
outputList[res] = ''
resEntry.append_text(res)
resEntry.set_active(1)
outputEntry = gtk.Entry()
table.attach(summaryEntry, 1,2, 0,1)
table.attach(resEntry, 1,2, 1,2)
table.attach(outputEntry, 1,2, 2,3)
newItemDialog.vbox.add(table)
newItemDialog.show_all()
while True:
response = newItemDialog.run()
if response == gtk.RESPONSE_OK:
# Check that the summary entry is okay.
summary = summaryEntry.get_text().strip()
if len(summary) <= 0:
msgDialog = gtk.MessageDialog(qaapp.app.ReviewerWindow,
gtk.DIALOG_DESTROY_WITH_PARENT,
gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE,
'You must enter a value for the Summary')
msgDialog.set_title('Invalid summary')
msgDialog.set_default_response(gtk.RESPONSE_CLOSE)
response = msgDialog.run()
msgDialog.destroy()
continue
resIndex = resEntry.get_active()
res = resList[resIndex]
output = outputEntry.get_text()
outputList[res] = output
try:
qaapp.app.checklist.add_entry(summary, desc=None,
item=True,
display=True,
resolution=res,
output=output,
resList=resList,
outputList=outputList)
except error.DuplicateItem:
msgDialog = gtk.MessageDialog(qaapp.app.ReviewerWindow,
gtk.DIALOG_DESTROY_WITH_PARENT,
gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE,
'The Summary must not be the same as any other'
' existing entry. Please consider renaming the'
' new checklist item or using the existing entry'
' for this review.')
msgDialog.set_title('Invalid summary')
msgDialog.set_default_response(gtk.RESPONSE_CLOSE)
response = msgDialog.run()
msgDialog.destroy()
continue
else:
break
else:
# User decided not to write a new entry
break
newItemDialog.destroy()
signature.asc
Description: This is a digitally signed message part
_______________________________________________ pygtk mailing list [email protected] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
