The following is a constructor of the gtk.FileChooserDialog class −
Dlg=gtk.FileChooserDialog (title = None, parent = None, action = gtk.FILE_CHOOSER_ACTION_OPEN, buttons = None, backend = None)The parameters are −
| title | This is the title of the dialog |
| parent | The transient parent of the dialog, or None |
| action | The open or save mode for the dialog |
| buttons | This is a tuple containing button label-response id pairs or None |
| backend | The name of the specific filesystem backend to use. |
- gtk.FILE_CHOOSER_ACTION_OPEN
- gtk.FILE_CHOOSER_ACTION_SAVE
- gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER
- gtk.FILE_CHOOSER_ACTION_CREATE_FOLDER
If the FileChooserDialog menu button is clicked, the following callback function is run.
def on_file(self, widget): dlg = gtk.FileChooserDialog("Open..", None, gtk.FILE_CHOOSER_ACTION_OPEN, (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK)) response = dlg.run() self.text.set_text(dlg.get_filename()) dlg.destroy()The file is selected from the dialog −
The selected file is displayed on the label on the toplevel gtk.Window −
No comments:
Post a Comment