Strumenti Utente

Strumenti Sito


pygtk:filechooserdialog

The standard way, in pygtk, to create a FileChooserDialog is something like:

fc = gtk.FileChooserDialog()
fc.add_buttons(gtk.STOCK_CANCEL, 0, gtk.STOCK_OK, 1)
resp = fc.run()

But what if you want the current selection to be chosen when you * double click it, or * press Enter?

Simple: call FileChooserDialog.set_default_response(), giving it the response you passed to the desired button:

fc = gtk.FileChooserDialog()
fc.add_buttons(gtk.STOCK_CANCEL, 0, gtk.STOCK_OK, 1)
fc.set_default_response( 1 )
resp = fc.run()
pygtk/filechooserdialog.txt · Ultima modifica: 2012/12/07 11:01 da pietro