Use new file dialogs.
authorJack Jansen <jack.jansen@cwi.nl>
Sun, 26 Jan 2003 22:15:48 +0000 (22:15 +0000)
committerJack Jansen <jack.jansen@cwi.nl>
Sun, 26 Jan 2003 22:15:48 +0000 (22:15 +0000)
Mac/Tools/IDE/ProfileBrowser.py
Mac/Tools/IDE/PyConsole.py
Mac/Tools/IDE/PyDocSearch.py
Mac/Tools/IDE/PyEdit.py
Mac/Tools/IDE/PythonIDEMain.py

index b3e9d990fec791a3606067b4ee63927251ce7e6d..c7a81ccebf9cee5b051224c3f48ed8823d548799 100644 (file)
@@ -1,5 +1,6 @@
 import W
 from Carbon import Evt
+import EasyDialogs
 
 import sys
 import StringIO
@@ -83,9 +84,9 @@ def main():
                browser = ProfileBrowser(stats)
        else:
                import macfs
-               fss, ok = macfs.PromptGetFile('Profiler data')
-               if not ok: sys.exit(0)
-               stats = pstats.Stats(fss.as_pathname())
+               filename = EasyDialogs.AskFileForOpen(message='Profiler data')
+               if not filename: sys.exit(0)
+               stats = pstats.Stats(filename)
                browser = ProfileBrowser(stats)
 
 if __name__ == '__main__':
index 3fae413987cb1aa73901aefa83079f1aac58bdea..27fc0cdf9dea132baea3d9472e29055df7656aa0 100644 (file)
@@ -10,6 +10,7 @@ import traceback
 import MacOS
 import MacPrefs
 from Carbon import Qd
+import EasyDialogs
 import PyInteractive
 
 if not hasattr(sys, 'ps1'):
@@ -85,10 +86,11 @@ class ConsoleTextWidget(W.EditText):
        
        def domenu_save_as(self, *args):
                import macfs
-               fss, ok = macfs.StandardPutFile('Save console text as:', 'console.txt')
-               if not ok:
+               filename = EasyDialogs.AskFileForSave(message='Save console text as:', 
+                       savedFileName='console.txt')
+               if not filename:
                        return
-               f = open(fss.as_pathname(), 'wb')
+               f = open(filename, 'wb')
                f.write(self.get())
                f.close()
                fss.SetCreatorType(W._signature, 'TEXT')
@@ -241,10 +243,11 @@ class OutputTextWidget(W.EditText):
        def domenu_save_as(self, *args):
                title = self._parentwindow.gettitle()
                import macfs
-               fss, ok = macfs.StandardPutFile('Save %s text as:' % title, title + '.txt')
-               if not ok:
+               filename = EasyDialogs.AskFileForSave(message='Save %s text as:' % title, 
+                       savedFileName=title + '.txt')
+               if not filename:
                        return
-               f = open(fss.as_pathname(), 'wb')
+               f = open(filename, 'wb')
                f.write(self.get())
                f.close()
                fss.SetCreatorType(W._signature, 'TEXT')
index 98eced916a6f6cbc9d8c6a97048cc91e68823b37..61d3959f6cd25aebb6a4693dbe9b68c3a661ec5a 100644 (file)
@@ -6,6 +6,7 @@ import MacPrefs
 import MacOS
 import string
 import webbrowser
+import EasyDialogs
 
 
 app = W.getapplication()
@@ -223,9 +224,8 @@ class PyDocSearch:
                        MacOS.SysBeep(0)
        
        def setdocpath(self):
-               fss, ok = macfs.GetDirectory()
-               if ok:
-                       docpath = fss.as_pathname()
+               docpath = EasyDialogs.AskFolder()
+               if docpath:
                        if not verifydocpath(docpath):
                                W.Message("This does not seem to be a Python documentation folder...")
                        else:
index 69266a870c2041bbde581dccb9a319904fdcf1c5..cd3f3ccd28153e88d67d839d9b674b0b1a2e148d 100644 (file)
@@ -7,6 +7,7 @@ from Wkeys import *
 import macfs
 import MACFS
 import MacOS
+import EasyDialogs
 from Carbon import Win
 from Carbon import Res
 from Carbon import Evt
@@ -67,7 +68,6 @@ class Editor(W.Window):
                self.path = path
                
                if '\n' in text:
-                       import EasyDialogs
                        if string.find(text, '\r\n') >= 0:
                                self._eoln = '\r\n'
                        else:
@@ -365,7 +365,6 @@ class Editor(W.Window):
        
        def close(self):
                if self.editgroup.editor.changed:
-                       import EasyDialogs
                        Qd.InitCursor()
                        save = EasyDialogs.AskYesNoCancel('Save window "%s" before closing?' % self.title,
                                        default=1, no="Don\xd5t save")
@@ -406,11 +405,11 @@ class Editor(W.Window):
                return self.editgroup.editor.changed or self.editgroup.editor.selchanged
        
        def domenu_save_as(self, *args):
-               fss, ok = macfs.StandardPutFile('Save as:', self.title)
-               if not ok
+               path = EasyDialogs.AskFileForSave(message='Save as:', savedFileName=self.title)
+               if not path
                        return 1
                self.showbreakpoints(0)
-               self.path = fss.as_pathname()
+               self.path = path
                self.setinfotext()
                self.title = os.path.split(self.path)[-1]
                self.wid.SetWTitle(self.title)
@@ -434,11 +433,11 @@ class Editor(W.Window):
                        destname = self.title[:-3]
                else:
                        destname = self.title + ".applet"
-               fss, ok = macfs.StandardPutFile('Save as Applet:', destname)
-               if not ok: 
+               destname = EasyDialogs.AskFileForSave(message='Save as Applet:', 
+                       savedFileName=destname)
+               if not destname: 
                        return 1
                W.SetCursor("watch")
-               destname = fss.as_pathname()
                if self.path:
                        filename = self.path
                        if filename[-3:] == ".py":
@@ -508,7 +507,6 @@ class Editor(W.Window):
        def _run(self):
                if self.run_with_interpreter:
                        if self.editgroup.editor.changed:
-                               import EasyDialogs
                                Qd.InitCursor()
                                save = EasyDialogs.AskYesNoCancel('Save "%s" before running?' % self.title, 1)
                                if save > 0:
@@ -521,7 +519,6 @@ class Editor(W.Window):
                        self._run_with_interpreter()
                elif self.run_with_cl_interpreter:
                        if self.editgroup.editor.changed:
-                               import EasyDialogs
                                Qd.InitCursor()
                                save = EasyDialogs.AskYesNoCancel('Save "%s" before running?' % self.title, 1)
                                if save > 0:
@@ -1025,7 +1022,6 @@ class SearchEngine:
                W.SetCursor("arrow")
                if counter:
                        self.hide()
-                       import EasyDialogs
                        from Carbon import Res
                        editor.textchanged()
                        editor.selectionchanged()
index 36ea339c798652f692d5c81dc8935977f5dadd3a..5b9376bbaea96bce1d151457180bfd12f036f78f 100644 (file)
@@ -9,6 +9,7 @@ import os
 import sys
 import macfs
 import MacOS
+import EasyDialogs
 
 if MacOS.runtimemodel == 'macho':
        ELIPSES = '...'
@@ -189,8 +190,9 @@ class PythonIDE(Wapplication.Application):
                Splash.about()
        
        def do_setscriptsfolder(self, *args):
-               fss, ok = macfs.GetDirectory("Select Scripts Folder")
-               if ok:
+               fss = EasyDialogs.AskFolder(message="Select Scripts Folder",
+                       wanted=macfs.FSSpec)
+               if fss:
                        prefs = self.getprefs()
                        alis = fss.NewAlias()
                        prefs.scriptsfolder = alis.data
@@ -204,9 +206,9 @@ class PythonIDE(Wapplication.Application):
                ModuleBrowser.ModuleBrowser()
        
        def domenu_open(self, *args):
-               fss, ok = macfs.StandardGetFile("TEXT")
-               if ok:
-                       self.openscript(fss.as_pathname())
+               filename = EasyDialogs.AskFileForOpen(typeList=("TEXT",))
+               if filename:
+                       self.openscript(filename)
        
        def domenu_new(self, *args):
                W.SetCursor('watch')
@@ -344,7 +346,6 @@ class PythonIDE(Wapplication.Application):
                # This is a cop-out. We should have disabled the menus
                # if there is no selection, but the can_ methods only seem
                # to work for Windows. Or not for the Help menu, maybe?
-               import EasyDialogs
                text = EasyDialogs.AskString("Search documentation for", ok="Search")
                return text