[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r9416 - trunk/gnue-forms/src/uidrivers/qt3/widgets
From: |
johannes |
Subject: |
[gnue] r9416 - trunk/gnue-forms/src/uidrivers/qt3/widgets |
Date: |
Wed, 28 Feb 2007 04:57:48 -0600 (CST) |
Author: johannes
Date: 2007-02-28 04:57:48 -0600 (Wed, 28 Feb 2007)
New Revision: 9416
Modified:
trunk/gnue-forms/src/uidrivers/qt3/widgets/form.py
Log:
Added implementation of select_files()
issue152 in-progress
Modified: trunk/gnue-forms/src/uidrivers/qt3/widgets/form.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt3/widgets/form.py 2007-02-28 08:42:46 UTC
(rev 9415)
+++ trunk/gnue-forms/src/uidrivers/qt3/widgets/form.py 2007-02-28 10:57:48 UTC
(rev 9416)
@@ -333,6 +333,79 @@
# -------------------------------------------------------------------------
+ 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)" % (desc, filt) for (desc, filt) in
wildcard])
+ dlg = qt.QFileDialog(default_dir, wst, self.main_window, "File Dialog",
+ True)
+ dlg.setCaption(title)
+
+ if multiple:
+ dmode = qt.QFileDialog.ExistingFiles
+ else:
+ dmode = qt.QFileDialog.ExistingFile
+
+ if mode.lower().startswith('save'):
+ dmode = qt.QFileDialog.AnyFile
+
+ dlg.setMode(dmode)
+
+ while True:
+ mres = dlg.exec_loop()
+
+ # User cancelled the dialog
+ if not mres:
+ result = None
+ break
+
+ if dmode == qt.QFileDialog.AnyFile:
+ fname = unicode(dlg.selectedFile())
+ if overwrite_prompt and os.path.exists(fname):
+ answ = self._ui_show_message_( \
+ u_("The file '%(file)s' already exists. " \
+ "Overwrite it?") % {'file': fname},
+ 'Question', u_("File already exists"), True)
+ if answ:
+ result = [fname]
+ break
+
+ elif dmode == qt.QFileDialog.ExistingFile:
+ result = [unicode(dlg.selectedFile())]
+ break
+ else:
+ result = [unicode(i) for i in dlg.selectedFiles()]
+ if result:
+ break
+
+ return result
+
+
+ # -------------------------------------------------------------------------
+
def _ui_show_about_(self, name, version, author, description):
"""
Show the about box describing the current application
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r9416 - trunk/gnue-forms/src/uidrivers/qt3/widgets,
johannes <=