[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r9414 - in trunk/gnue-forms/src: . uidrivers/wx26/widgets
From: |
johannes |
Subject: |
[gnue] r9414 - in trunk/gnue-forms/src: . uidrivers/wx26/widgets |
Date: |
Wed, 28 Feb 2007 02:12:15 -0600 (CST) |
Author: johannes
Date: 2007-02-28 02:12:13 -0600 (Wed, 28 Feb 2007)
New Revision: 9414
Modified:
trunk/gnue-forms/src/GFForm.py
trunk/gnue-forms/src/uidrivers/wx26/widgets/form.py
Log:
Started namespace methods for File- and Dir-Selection dialogs
issue152 in-progress
Modified: trunk/gnue-forms/src/GFForm.py
===================================================================
--- trunk/gnue-forms/src/GFForm.py 2007-02-26 18:11:22 UTC (rev 9413)
+++ trunk/gnue-forms/src/GFForm.py 2007-02-28 08:12:13 UTC (rev 9414)
@@ -167,6 +167,7 @@
'beep': {'function': self.beep, 'global': True},
'status_message': {'function': self.status_message},
'show_message': {'function': self.show_message},
+ 'select_files': {'function': self.select_files},
# User feedback - depreciated
'setStatusText': {
@@ -770,7 +771,45 @@
title = self.title
return self.uiWidget._ui_show_message_(message, kind, title,
cancel)
+ # -------------------------------------------------------------------------
+ def select_files(self, title, default_dir, default_file, wildcard=[],
+ mode='open', multiple=False, overwrite_prompt=True,
+ file_must_exist=False):
+ """
+ Bring up a dialog for selecting filenames.
+
+ @param title: Message to show on the dialog
+ @param default_dir: the default directory, or the empty string
+ @param default_file: the default filename, or the empty string
+ @param wildcard: a list of tuples describing the filters used by the
+ dialog. Such a tuple constists of a description and a fileter.
+ Example: [('PNG Files', '*.png'), ('JPEG Files', '*.jpg')]
+ If no wildcard is given, all files will match (*.*)
+ @param mode: Is this dialog an open- or a save-dialog. If mode is
+ 'save' it is a save dialog, everything else would be an
+ open-dialog.
+ @param multiple: for open-dialog only: if True, allows selecting
+ multiple files
+ @param overwrite_prompt: for save-dialog only: if True, prompt for a
+ confirmation if a file will be overwritten
+ @param file_must_exist: if True, the user may only select files that
+ actually exist
+
+ @returns: a sequence of filenames or None if the dialog has been
+ cancelled.
+ """
+ if self.uiWidget is not None:
+ return self.uiWidget._ui_select_files_(title, default_dir,
+ default_file, wildcard, mode, multiple, overwrite_prompt,
+ file_must_exist)
+
+ # -------------------------------------------------------------------------
+
+ def dir_selector(self):
+ pass
+
+
# =========================================================================
# Clipboard and selection
# =========================================================================
Modified: trunk/gnue-forms/src/uidrivers/wx26/widgets/form.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/form.py 2007-02-26 18:11:22 UTC
(rev 9413)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/form.py 2007-02-28 08:12:13 UTC
(rev 9414)
@@ -456,7 +456,68 @@
return _RESPONSE[result]
+ # -------------------------------------------------------------------------
+ # Show a file selection dialog
+ # -------------------------------------------------------------------------
+ def _ui_select_files_(self, title, default_dir, default_file, wildcard,
+ mode, multiple, overwrite_prompt, file_must_exist):
+ """
+ Bring up a dialog for selecting filenames.
+
+ @param title: Message to show on the dialog
+ @param default_dir: the default directory, or the empty string
+ @param default_file: the default filename, or the empty string
+ @param wildcard: a list of tuples describing the filters used by the
+ dialog. Such a tuple constists of a description and a fileter.
+ Example: [('PNG Files', '*.png'), ('JPEG Files', '*.jpg')]
+ If no wildcard is given, all files will match (*.*)
+ @param mode: Is this dialog an open- or a save-dialog. If mode is
+ 'save' it is a save dialog, everything else would be an
+ open-dialog.
+ @param multiple: for open-dialog only: if True, allows selecting
+ multiple files
+ @param overwrite_prompt: for save-dialog only: if True, prompt for a
+ confirmation if a file will be overwritten
+ @param file_must_exist: if True, the user may only select files that
+ actually exist
+
+ @returns: a sequence of filenames or None if the dialog has been
+ cancelled.
+ """
+
+ wst = '|'.join(['%s|%s' % (descr, filt) for (descr, filt) in wildcard])
+ if not wst:
+ wst = '%s (*.*)|*.*' % u_('All files')
+
+ if mode.lower().startswith('save'):
+ flags = wx.SAVE
+ if overwrite_prompt:
+ flags |= wx.OVERWRITE_PROMPT
+ else:
+ flags = wx.OPEN
+ if multiple:
+ flags |= wx.MULTIPLE
+
+ if file_must_exist:
+ flags |= wx.FILE_MUST_EXIST
+
+ dlg = wx.FileDialog(self.main_window, title, default_dir, default_file,
+ wst, flags)
+ try:
+ result = None
+ mres = dlg.ShowModal()
+ if mres == wx.ID_OK:
+ if multiple:
+ result = dlg.GetPaths()
+ else:
+ result = [dlg.GetPath()]
+ finally:
+ dlg.Destroy()
+
+ return result
+
+
# -------------------------------------------------------------------------
# Set title of form
# -------------------------------------------------------------------------
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r9414 - in trunk/gnue-forms/src: . uidrivers/wx26/widgets,
johannes <=