commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnue] r9415 - in trunk/gnue-forms/src: . uidrivers/wx26/widgets


From: johannes
Subject: [gnue] r9415 - in trunk/gnue-forms/src: . uidrivers/wx26/widgets
Date: Wed, 28 Feb 2007 02:42:47 -0600 (CST)

Author: johannes
Date: 2007-02-28 02:42:46 -0600 (Wed, 28 Feb 2007)
New Revision: 9415

Modified:
   trunk/gnue-forms/src/GFForm.py
   trunk/gnue-forms/src/uidrivers/wx26/widgets/form.py
Log:
Add directory selection dialog

issue152 in-progress


Modified: trunk/gnue-forms/src/GFForm.py
===================================================================
--- trunk/gnue-forms/src/GFForm.py      2007-02-28 08:12:13 UTC (rev 9414)
+++ trunk/gnue-forms/src/GFForm.py      2007-02-28 08:42:46 UTC (rev 9415)
@@ -168,6 +168,7 @@
             'status_message': {'function': self.status_message},
             'show_message': {'function': self.show_message},
             'select_files': {'function': self.select_files},
+            'select_dir': {'function': self.select_dir},
 
             # User feedback - depreciated
             'setStatusText': {
@@ -806,10 +807,23 @@
 
     # -------------------------------------------------------------------------
 
-    def dir_selector(self):
-        pass
+    def select_dir(self, title, default_dir, new_dir=False):
+        """
+        Bring up a dialog for selecting a directory path.
 
+        @param title: Message to show on the dialog
+        @param default_dir: the default directory, or the empty string
+        @param new_dir: If true, add "Create new directory" button and allow
+            directory names to be editable. On Windows the new directory button
+            is only available with recent versions of the common dialogs.
 
+        @returns: a path or None if the dialog has been cancelled.
+        """
+        if self.uiWidget is not None:
+            return self.uiWidget._ui_select_dir_(title, default_dir, new_dir)
+
+
+
     # =========================================================================
     # Clipboard and selection
     # =========================================================================

Modified: trunk/gnue-forms/src/uidrivers/wx26/widgets/form.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/form.py 2007-02-28 08:12:13 UTC 
(rev 9414)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/form.py 2007-02-28 08:42:46 UTC 
(rev 9415)
@@ -517,7 +517,41 @@
 
         return result
 
+    # -------------------------------------------------------------------------
+    # Select a directory
+    # -------------------------------------------------------------------------
 
+    def _ui_select_dir_(self, title, default_dir, new_dir):
+        """
+        Bring up a dialog for selecting a directory path.
+
+        @param title: Message to show on the dialog
+        @param default_dir: the default directory, or the empty string
+        @param new_dir: If true, add "Create new directory" button and allow
+            directory names to be editable. On Windows the new directory button
+            is only available with recent versions of the common dialogs.
+
+        @returns: a path or None if the dialog has been cancelled.
+        """
+        
+        if new_dir:
+            flags = wx.DD_NEW_DIR_BUTTON
+        else:
+            flags = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER
+
+        dlg = wx.DirDialog(self.main_window, title, default_dir, flags)
+        try:
+            result = None
+            mres = dlg.ShowModal()
+            if mres == wx.ID_OK:
+                result = dlg.GetPath()
+
+        finally:
+            dlg.Destroy()
+            
+        return result
+
+
     # -------------------------------------------------------------------------
     # Set title of form
     # -------------------------------------------------------------------------





reply via email to

[Prev in Thread] Current Thread [Next in Thread]