Open GoogleCodeExporter opened 9 years ago
Try giving an explicit filename to save to, for instance
>>> s.save(r"C:\directory\that\you\know\exists\tmp.svg")
If you don't give save() an explicit filename, it tries to put a new file (or
overwrite an old file) named "tmp.svg" in a reasonable place. If you're using
Mac or
Linux, the place where you're running Python is a reasonable place. If you're
using
Windows, Python lives in some strange C:\Python26\lib\ directory, where the user
doesn't often venture, and so my Windows test-user complained that this was a
bad
place. A much better place, for a Windows user, is on the Desktop (where just
about
everything goes). So the following code is used to find where the Desktop is:
if re.search("windows", platform.system(), re.I):
try:
import _winreg
_default_directory =
_winreg.QueryValueEx(_winreg.OpenKey(_winreg.HKEY_CURRENT_USER, \
r"Software\Microsoft\Windows\Current Version\Explorer\Shell
Folders"), "Desktop")[0]
# tmpdir = _winreg.QueryValueEx(_winreg.OpenKey(_winreg.HKEY_CURRENT_USER,
"Environment"), "TEMP")[0]
# if tmpdir[0:13] != "%USERPROFILE%":
# tmpdir = os.path.expanduser("~") + tmpdir[13:]
except:
_default_directory = os.path.expanduser("~") + os.sep + "Desktop"
The commented-out part chooses the Windows temporary directory--- another place
the
user doesn't often visit.
It's quite possible that this bit of code, which worked fine on Windows XP,
doesn't
work on Windows Vista because they might have changed the way things are
structured.
If so, does anyone have any input on how this should work now, and possibly also how
to test for XP-versus-Vista (assuming that's the difference we're talking
about)?
Original comment by jpivar...@gmail.com
on 19 Feb 2010 at 1:45
Original issue reported on code.google.com by
kenauc...@gmail.com
on 18 Feb 2010 at 11:52