Hi Folks,
The leo script below _almost_ adds an icon to .leo files in Windows. I say
almost in that on my system it runs without error, the associated registry
key is created and contains the right path, but Windows still doesn't know
what to do with the file.
It's intended to be run after "create-leobat" has been run and the Leo.File
filetype is already present.
Anyone else have some ideas how to improve it?
thanks!
-matt
{{{
<?xml version="1.0" encoding="utf-8"?>
<!-- Created by Leo (http://webpages.charter.net/edreamleo/front.html) -->
<?xml-stylesheet ekr_test?>
<leo_file xmlns:leo="http://www.leo-editor.org/2011/leo" >
<leo_header file_format="2"/>
<vnodes>
<v t="maphew.20130509185752.1607"><vh>Set icon for .leo files</vh></v>
</vnodes>
<tnodes>
<t tx="maphew.20130509185752.1607">from _winreg import *
def register_leo_icon():
'''Tell Windows what icon to use for the Leo.File filetype (.leo)
Resources:
http://stackoverflow.com/questions/2331690/how-to-set-a-icon-file-while-creating-file
http://stackoverflow.com/questions/771689/how-can-i-set-an-icon-for-my-own-file-extension
'''
icon = "%s\Icons\LeoDoc.ico" % g.computeLeoDir()
g.es("\nAttempting to register leo icon with .leo files...")
if g.os_path_exists(icon):
g.es("Found:", icon)
myTestKey = OpenKey(HKEY_CLASSES_ROOT, "Leo.File")
iconKey= CreateKey(myTestKey, "DefaultIcon")
CloseKey(myTestKey)
SetValue(iconKey, None, REG_SZ, icon)
CloseKey(iconKey)
g.es("Registered!")
else:
g.es("LeoDoc.ico not in expected location, can't continue.")
</t>
</tnodes>
</leo_file>
}}}
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/leo-editor?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.