]> granicus.if.org Git - python/commitdiff
Use new file dialogs.
authorJack Jansen <jack.jansen@cwi.nl>
Sun, 26 Jan 2003 21:40:00 +0000 (21:40 +0000)
committerJack Jansen <jack.jansen@cwi.nl>
Sun, 26 Jan 2003 21:40:00 +0000 (21:40 +0000)
16 files changed:
Mac/Demo/imgbrowse/imgbrowse.py
Mac/Demo/mlte/mlted.py
Mac/Demo/quicktime/MovieInWindow.py
Mac/Demo/quicktime/VerySimplePlayer.py
Mac/Demo/textedit/ped.py
Mac/Demo/waste/htmled.py
Mac/Demo/waste/swed.py
Mac/Demo/waste/wed.py
Mac/Tools/macfreeze/macgen_bin.py
Mac/scripts/EditPythonPrefs.py
Mac/scripts/findgremlins.py
Mac/scripts/fixfiletypes.py
Mac/scripts/fullbuild.py
Mac/scripts/makeclean.py
Mac/scripts/unshar.py
Mac/scripts/zappycfiles.py

index b54f82b0cc6370850495b8b55c8ab591e1b41468..d8164eaebe047066f789a98e97ae849725076232 100644 (file)
@@ -1,4 +1,4 @@
-GetPortBounds()"""imgbrowse - Display pictures using img"""
+"""imgbrowse - Display pictures using img"""
 
 import FrameWork
 import EasyDialogs
@@ -11,7 +11,6 @@ import sys
 import struct
 import img
 import imgformat
-import macfs
 import struct
 import mac_image
 
@@ -47,11 +46,10 @@ class imgbrowse(FrameWork.Application):
                self._quit()
                
        def opendoc(self, *args):
-               fss, ok = macfs.StandardGetFile() # Any file type
-               if not ok:
+               pathname = EasyDialogs.AskFileForOpen() # Any file type
+               if not pathname:
                        return
                bar = EasyDialogs.ProgressBar('Reading and converting...')
-               pathname = fss.as_pathname()
                try:
                        rdr = img.reader(imgformat.macrgb16, pathname)
                except img.error, arg:
index 3f77eeedde91f0fa05db6a9c72e625c7811e519c..53f9f5dae0819e519f117967b99566cdc3978c92 100644 (file)
@@ -11,7 +11,6 @@ from Carbon import Qd
 from Carbon import Res
 from Carbon import Scrap
 import os
-import macfs
 from Carbon import MacTextEditor
 from Carbon import Mlte
 
@@ -92,9 +91,9 @@ class MlteWindow(Window):
                self.changed = 0
                
        def menu_save_as(self):
-               fss, ok = macfs.StandardPutFile('Save as:')
-               if not ok: return
-               self.path = fss.as_pathname()
+               path = EasyDialogs.AskFileForSave(message='Save as:')
+               if not path: return
+               self.path = path
                self.name = os.path.split(self.path)[-1]
                self.wid.SetWTitle(self.name)
                self.menu_save()
@@ -268,10 +267,9 @@ class Mlted(Application):
 
        def _open(self, askfile):
                if askfile:
-                       fss, ok = macfs.StandardGetFile('TEXT')
-                       if not ok:
+                       path = EasyDialogs.AskFileForOpen(typeList=('TEXT',))
+                       if not path:
                                return
-                       path = fss.as_pathname()
                        name = os.path.split(path)[-1]
                        try:
                                fp = open(path, 'rb') # NOTE binary, we need cr as end-of-line
index 620c16c6f0b0071f749ccc20c5058e4d0f3b2efc..0df30a4ac9306432af6161bdff127bcba7629898 100644 (file)
@@ -11,7 +11,8 @@ from Carbon import Evt
 from Carbon import Events
 from Carbon import Win
 from Carbon import Windows
-import macfs
+from Carbon import File
+import EasyDialogs
 import sys
 
 
@@ -21,8 +22,8 @@ def main():
        Qt.EnterMovies()
        
        # Get the movie file
-       fss, ok = macfs.StandardGetFile() # Was: QuickTime.MovieFileType
-       if not ok:
+       fss = EasyDialogs.AskFileForOpen(wanted=File.FSSpec) # Was: QuickTime.MovieFileType
+       if not fss:
                sys.exit(0)
                
        # Open the window
index aca977f07458ee6c0c47b3a08ef59da0fe66d416..de64e3f006384b1fb762e1bd5cdf1b4978c840b2 100644 (file)
@@ -11,7 +11,8 @@ from Carbon import Evt
 from Carbon import Events
 from Carbon import Win
 from Carbon import Windows
-import macfs
+from Carbon import File
+import EasyDialogs
 import sys
 
 # XXXX maxbounds = (40, 40, 1000, 1000)
@@ -23,8 +24,8 @@ def main():
        Qt.EnterMovies()
        
        # Get the movie file
-       fss, ok = macfs.StandardGetFile(QuickTime.MovieFileType)
-       if not ok:
+       fss = EasyDialogs.AskFileForOpen(wanted=File.FSSpec) # Was: QuickTime.MovieFileType
+       if not fss:
                sys.exit(0)
                
        # Open the window
index 666615895a3b2616a93d4963888d5c18243c7a96..80cf7e5ce8b35508e947924a13407138b8efe7df 100644 (file)
@@ -131,9 +131,9 @@ class TEWindow(ScrolledWindow):
                self.changed = 0
                
        def menu_save_as(self):
-               fss, ok = macfs.StandardPutFile('Save as:')
-               if not ok: return
-               self.path = fss.as_pathname()
+               path = EasyDialogs.AskFileForSave(message='Save as:')
+               if not path: return
+               self.path = path
                self.name = os.path.split(self.path)[-1]
                self.wid.SetWTitle(self.name)
                self.menu_save()
@@ -265,10 +265,9 @@ class Ped(Application):
 
        def _open(self, askfile):
                if askfile:
-                       fss, ok = macfs.StandardGetFile('TEXT')
-                       if not ok:
+                       path = EasyDialogs.AskFileForOpen(typeList=('TEXT',))
+                       if not path:
                                return
-                       path = fss.as_pathname()
                        name = os.path.split(path)[-1]
                        try:
                                fp = open(path, 'rb') # NOTE binary, we need cr as end-of-line
index 3abbafaef72b5d9b66640be70d51a804fd4e172f..d415de13f26745116d337e9d3f1371b8a576494a 100644 (file)
@@ -13,8 +13,8 @@ import waste
 import WASTEconst
 from Carbon import Scrap
 import os
+import EasyDialogs
 import macfs
-import MACFS
 import string
 import htmllib
 
@@ -243,7 +243,7 @@ class WasteWindow(ScrolledWindow):
                try:
                        rf = Res.FSpOpenResFile(self.path, 3)
                except Res.Error:
-                       Res.FSpCreateResFile(self.path, '????', 'TEXT', MACFS.smAllScripts)
+                       Res.FSpCreateResFile(self.path, '????', 'TEXT', macfs.smAllScripts)
                        rf = Res.FSpOpenResFile(self.path, 3)
                styles = Res.Resource('')
                soup = Res.Resource('')
@@ -256,9 +256,9 @@ class WasteWindow(ScrolledWindow):
                self.ted.WEResetModCount()
                
        def menu_save_as(self):
-               fss, ok = macfs.StandardPutFile('Save as:')
-               if not ok: return
-               self.path = fss.as_pathname()
+               path = EasyDialogs.AskFileForSave(message='Save as:')
+               if not path: return
+               self.path = path
                self.name = os.path.split(self.path)[-1]
                self.wid.SetWTitle(self.name)
                self.menu_save()
@@ -661,10 +661,9 @@ class Wed(Application):
 
        def _open(self, askfile):
                if askfile:
-                       fss, ok = macfs.StandardGetFile('TEXT')
-                       if not ok:
+                       path = EasyDialogs.AskFileForOpen(typeList=('TEXT',))
+                       if not path:
                                return
-                       path = fss.as_pathname()
                        name = os.path.split(path)[-1]
                        try:
                                fp = open(path, 'rb') # NOTE binary, we need cr as end-of-line
@@ -683,10 +682,9 @@ class Wed(Application):
 
        def insertfile(self, *args):
                if self.active:
-                       fss, ok = macfs.StandardGetFile('TEXT')
-                       if not ok:
+                       path = EasyDialogs.AskFileForOpen(typeList=('TEXT',))
+                       if not path:
                                return
-                       path = fss.as_pathname()
                        try:
                                fp = open(path, 'rb') # NOTE binary, we need cr as end-of-line
                        except IOError, arg:
@@ -698,10 +696,9 @@ class Wed(Application):
 
        def inserthtml(self, *args):
                if self.active:
-                       fss, ok = macfs.StandardGetFile('TEXT')
-                       if not ok:
+                       path = EasyDialogs.AskFileForOpen(typeList=('TEXT',))
+                       if not path:
                                return
-                       path = fss.as_pathname()
                        try:
                                fp = open(path, 'r')
                        except IOError, arg:
index 083a04c05a13011019bf938d565c1f26dbb422fa..c85cb21c226fcba94391bfa8ce765a842003380a 100644 (file)
@@ -14,7 +14,6 @@ import WASTEconst
 from Carbon import Scrap
 import os
 import macfs
-import MACFS
 
 UNDOLABELS = [ # Indexed by WEGetUndoInfo() value
        None, "", "typing", "Cut", "Paste", "Clear", "Drag", "Style"]
@@ -213,7 +212,7 @@ class WasteWindow(ScrolledWindow):
                try:
                        rf = Res.FSpOpenResFile(self.path, 3)
                except Res.Error:
-                       Res.FSpCreateResFile(self.path, '????', 'TEXT', MACFS.smAllScripts)
+                       Res.FSpCreateResFile(self.path, '????', 'TEXT', macfs.smAllScripts)
                        rf = Res.FSpOpenResFile(self.path, 3)
                styles = Res.Resource('')
                soup = Res.Resource('')
@@ -226,9 +225,9 @@ class WasteWindow(ScrolledWindow):
                self.ted.WEResetModCount()
                
        def menu_save_as(self):
-               fss, ok = macfs.StandardPutFile('Save as:')
-               if not ok: return
-               self.path = fss.as_pathname()
+               path = EasyDialogs.AskFileForSave(message='Save as:')
+               if not path: return
+               self.path = path
                self.name = os.path.split(self.path)[-1]
                self.wid.SetWTitle(self.name)
                self.menu_save()
@@ -521,10 +520,9 @@ class Wed(Application):
 
        def _open(self, askfile):
                if askfile:
-                       fss, ok = macfs.StandardGetFile('TEXT')
-                       if not ok:
+                       path = EasyDialogs.AskFileForOpen(typeList=('TEXT',))
+                       if not path:
                                return
-                       path = fss.as_pathname()
                        name = os.path.split(path)[-1]
                        try:
                                fp = open(path, 'rb') # NOTE binary, we need cr as end-of-line
index 199201b53fe2c40ecbbce6002620ecc45ff380de..7161ae5bbbb5f04bbfe8944bf71f8fddf6f683ae 100644 (file)
@@ -12,7 +12,7 @@ import waste
 import WASTEconst
 from Carbon import Scrap
 import os
-import macfs
+import EasyDialogs
 
 UNDOLABELS = [ # Indexed by WEGetUndoInfo() value
        None, "", "typing", "Cut", "Paste", "Clear", "Drag", "Style"]
@@ -181,9 +181,9 @@ class WasteWindow(ScrolledWindow):
                self.changed = 0
                
        def menu_save_as(self):
-               fss, ok = macfs.StandardPutFile('Save as:')
-               if not ok: return
-               self.path = fss.as_pathname()
+               path = EasyDialogs.AskFileForSave(message='Save as:')
+               if not path: return
+               self.path = path
                self.name = os.path.split(self.path)[-1]
                self.wid.SetWTitle(self.name)
                self.menu_save()
@@ -329,10 +329,9 @@ class Wed(Application):
 
        def _open(self, askfile):
                if askfile:
-                       fss, ok = macfs.StandardGetFile('TEXT')
-                       if not ok:
+                       path = EasyDialogs.AskFileForOpen(typeList=('TEXT',))
+                       if not path:
                                return
-                       path = fss.as_pathname()
                        name = os.path.split(path)[-1]
                        try:
                                fp = open(path, 'rb') # NOTE binary, we need cr as end-of-line
index a6de84af059fe94be851f8890aab81cba9b459d7..8735e171db3faa68dc6f744dc4edc9802df48b5a 100644 (file)
@@ -205,10 +205,10 @@ def findpythoncore():
                raise "Unknown MacOS.runtimemodel", MacOS.runtimemodel
        corepath = os.path.join(extpath, corename)
        if not os.path.exists(corepath):
-               fss, ok = macfs.PromptGetFile("Please locate PythonCore:", "shlb")
-               if not ok:
+               corepath = EasyDialogs.AskFileForOpen(message="Please locate PythonCore:", 
+                       typeList=("shlb",))
+               if not corepath:
                        raise KeyboardInterrupt, "cancelled"
-               corepath = fss.as_pathname()
        return resolvealiasfile(corepath)
 
 def resolvealiasfile(path):
index d9a0c5d3e53d6d40008107e3898586dfae468f2d..9e9c3702e8b69690d7695e31c0a315571dde01c0 100644 (file)
@@ -159,7 +159,8 @@ def interact(options, title):
 ##             if n == REVERT_ITEM:
 ##                     return [], pythondir
                if n == DIR_ITEM:
-                       fss, ok = macfs.GetDirectory('Select python home folder:')
+                       fss = EasyDialogs.AskFolder(message='Select python home folder:',
+                               wanted=macfs.FSSpec)
                        if ok:
                                options['dir'] = fss
                elif n == HELP_ITEM and Help:
index fe40e648a4584610d5b4d2da77534f31951a231f..595551e6724c11441b4823bafa996bfb9e58cfd9 100644 (file)
@@ -4,6 +4,7 @@ the filename and a bit of context.
 
 By Just, with a little glue by Jack"""
 
+import EasyDialogs
 import macfs
 import re
 import os
@@ -43,9 +44,9 @@ def walk(top, recurse=1):
                                pos = j
 
 def main():
-       fss, ok = macfs.GetDirectory()
-       if ok:
-               walk(fss.as_pathname())
+       pathname = EasyDialogs.AskFolder()
+       if pathname:
+               walk(pathname)
                
 if __name__ == '__main__':
        main()
index 284b5e1234129b6af010fdfdcfc4fc54bef82256..872c891e99fae52e441a4382f7c0550964a740b8 100644 (file)
@@ -9,6 +9,7 @@
 #
 import os
 import macfs
+import EasyDialogs
 import sys
 import macostools
 
@@ -45,10 +46,10 @@ def walktree(name, change):
                        walktree(os.path.join(name, f), change)
                        
 def run(change):
-       fss, ok = macfs.GetDirectory('Folder to search:')
-       if not ok:
+       pathname = EasyDialogs.AskFolder(message='Folder to search:')
+       if not pathname:
                sys.exit(0)
-       walktree(fss.as_pathname(), change)
+       walktree(pathname, change)
        
 if __name__ == '__main__':
        run(1)
index 1a8fc6dcc6fff6f1cc463c7946312705c7be5661..b1cd2d88ed6b656267c76f698b624f6f9550eea0 100644 (file)
@@ -410,10 +410,9 @@ def incbuildno(filename):
                                
 def main():
        macresource.need('DLOG', DIALOG_ID, 'fullbuild.rsrc')
-       dir, ok = macfs.GetDirectory('Python source folder:')
-       if not ok:
+       dir = EasyDialogs.AskFolder(message='Python source folder:')
+       if not dir:
                sys.exit(0)
-       dir = dir.as_pathname()
        # Set genpluginprojects to use this folder (slight hack)
        genpluginprojects.PYTHONDIR = dir
        
index 005ea02ede2fbec9caa752955323521665bf7a3e..14416abb27c03dcce779e908dd324ac9d7ab5f76 100644 (file)
@@ -12,6 +12,7 @@
 """
 
 import macfs
+import EasyDialogs
 import os
 import sys
 import re
@@ -53,7 +54,7 @@ def walk(top):
                        remove(top)
                
 
-fss, ok = macfs.GetDirectory("Please locate the Python home directory")
-if ok:
-       walk(fss.as_pathname())
+pathname = EasyDialogs.AskFolder(message="Please locate the Python home directory")
+if pathname:
+       walk(pathname)
        sys.exit(1)  # so we see the results
index a90ee342bd655c9bb52a116089633604a2886058..ec14f2ebfdf57fece2c85b0cc101e57ccda8ef8a 100644 (file)
@@ -6,6 +6,7 @@
 # >>> unshar.unshar(f)
 
 import string
+import EasyDialogs
 
 def unshar(fp, verbose=0, overwrite=0):
        ofp = None
@@ -82,15 +83,14 @@ def main():
                        unshar(fp)
        else:
                import macfs
-               fss, ok = macfs.StandardGetFile('TEXT')
-               if not ok:
+               fname = EasyDialogs.AskFileForOpen()
+               if not fname:
                        sys.exit(0)
-               fname = fss.as_pathname()
                fp = open(fname, 'r')
-               fss, ok = macfs.GetDirectory('Folder to save files in:')
-               if not ok:
+               dirname = EasyDialogs.AskFolder(message='Folder to save files in:')
+               if not dirname:
                        sys.exit(0)
-               os.chdir(fss.as_pathname())
+               os.chdir(dirname)
                unshar(fp)
                
 if __name__ == '__main__':
index dcd41334c6758d2a832bb012b81e8a4b8d01359b..4637159049684a1f623b70a831151bdfe7eb2770 100644 (file)
@@ -2,6 +2,7 @@
 """Recursively zap all .pyc and .pyo files"""
 import os
 import sys
+import EasyDialogs
 
 # set doit true to actually delete files
 # set doit false to just print what would be deleted
@@ -11,10 +12,9 @@ def main():
        if not sys.argv[1:]:
                if os.name == 'mac':
                        import macfs
-                       fss, ok = macfs.GetDirectory('Directory to zap pyc files in')
-                       if not ok:
+                       dir = EasyDialogs.AskFolder(message='Directory to zap pyc files in')
+                       if not dir:
                                sys.exit(0)
-                       dir = fss.as_pathname()
                        zappyc(dir)
                else:
                        print 'Usage: zappyc dir ...'