- PyGTK - Drag and Drop
- PyGTK - Timeout
- PyGTK - Ruler Class
- PyGTK - Clipboard Class
- PyGTK - Calendar Class
- PyGTK - SpinButton Class
- PyGTK - DrawingArea Class
- PyGTK - Image Class
- PyGTK - Arrow Class
- PyGTK - Scrolledwindow Class
- PyGTK - Viewport Class
- PyGTK - ProgressBar Class
- PyGTK - Statusbar Class
- PyGTK - Paned Class
- PyGTK - TreeView Class
- PyGTK - AspectFrame Class
- PyGTK - Frame Class
- PyGTK - Notebook Class
- PyGTK - File Chooser Dialog
- PyGTK - Color Selection Dialog
- PyGTK - Font Selection Dialog
- PyGTK - AboutDialog Class
- PyGTK - MessageDialog Class
- PyGTK - Dialog Class
- PyGTK - Scrollbar Class
- PyGTK - Scale Class
- PyGTK - Range Class
- PyGTK - Adjustment Class
- PyGTK - Toolbar Class
- PyGTK - MenuBar, Menu & MenuItem
- PyGTK - RadioButton Class
- PyGTK - CheckButton Class
- PyGTK - ToggleButton Class
- PyGTK - ComboBox Class
- PyGTK - Layout Class
- PyGTK - EventBox Class
- PyGTK - Alignment Class
- PyGTK - ButtonBox Class
- PyGTK - Box Class
- PyGTK - Containers
- PyGTK - Event Handling
- PyGTK - Signal Handling
- PyGTK - Entry Class
- PyGTK - Label CLass
- PyGTK - Button Class
- PyGTK - Window Class
- PyGTK - Important Classes
- PyGTK - Hello World
- PyGTK - Environment
- PyGTK - Introduction
- PyGTK - Home
PyGTK Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
PyGTK - File Chooser Dialog
This dialog is useful to let the user select the location and the name of file that needs to be opened or saved. It embeds FileChooserWidget and provides OK and CANCEL buttons in the action_area.
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. |
The following are the action modes −
gtk.FILE_CHOOSER_ACTION_OPEN
gtk.FILE_CHOOSER_ACTION_SAVE
gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER
gtk.FILE_CHOOSER_ACTION_CREATE_FOLDER
If it is desired to restrict the types of files to be available for display, an object of the gtk.FileFilter can be appped by using the add_filter() method.
If the FileChooserDialog menu button is cpcked, 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 −
Advertisements