On Friday 13 February 2009 11:03:41 am Ricardo Aráoz wrote:
> One of the things I was most missing from my VFP environment is the "set
> default to getdir()" statement. So I thought I could do something about
> it. I'm sharing it here for those old VFP hands who may need it.
>
> You use it thus :
> >>> import fox
> >>> fox.setDefault(fox.getDir())
>
> -----------------------------------------------------
> A nice window allows you to pick a directory
> -----------------------------------------------------
>
> >>> import os
> >>> os.getcwd()
>
> 'C:\\whatever\\dir
>
> >>> fox.getDir()
>
> -----------------------------------------------------
> A nice window allows you to pick a directory
> -----------------------------------------------------
> 'C:/WINDOWS/Config'
>
> >>> fox.getFile()
>
> -----------------------------------------------------
> A nice window allows you to pick a file
> -----------------------------------------------------
> 'C:/WINDOWS/Cursors/BEAM_IL.CUR'
>
>
> Hope this is useful. I've used Tkinter because this allows me to use the
> utility in IDLE, pythonWin, and PyCrust. Have tried with wx but it works
> different in IDLE than PyCrust due to the fact that in PyCrust there is
> a wx event loop already working (so I would have had to try and detect
> if there was such an event loop).
> Raised this question in a list and got this answer :
> """
> You could try something like:
>
> wx.CallAfter(lambda: None)
>
> Here's what I get in a quick test with no app running:
> >>> import wx
> >>> wx.CallAfter(lambda: None)
>
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File
> "//Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-pack
>ages/wx-2.8-mac-unicode/wx/_core.py", line 14359, in CallAfter
>     assert app is not None, 'No wx.App created yet'
> AssertionError: No wx.App created yet
>
> Whereas if I do the same thing from pycrust, nothing happens (that is,
> presumably my lambda executes).
> """
>
> If somebody comes up with a way of coding this in dabo (without going into
> too much hassle trying to detect wx) I'd be happy to know. Any
> contributions to fox utilities is welcome, I'm planning on a
> browse(micursor) function to browse an already created cursor. Here's the
> code :
> -----------------------------------------------------
> Fox.py :
> ======
> from __fox import getDir, setDefault, getFile
> -----------------------------------------------------
>
> -----------------------------------------------------
> __fox.py :
> ========
> import Tkinter, tkFileDialog
> import os
>
> def getDir() :
>     root = Tkinter.Tk()
>     root.withdraw()
>     path = tkFileDialog.askdirectory(parent=root, title='Choose directory
> ...') root.destroy()
>     return path
>
> def setDefault(path) :
>     if path :
>         os.chdir(path)
>
> def getFile() :
>     root = Tkinter.Tk()
>     root.withdraw()
>     file = tkFileDialog.askopenfilename(parent=root, title='Choose File
> ...') root.destroy()
>     return file
> -----------------------------------------------------
>
>
> HTH
> Ricardo

Of course you realize that under Dabo we have
dFileDialog and dFolderDialog



-- 
John Fabiani

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: 
http://leafe.com/archives/byMID/[email protected]

Reply via email to