[wxPython-users] Re: Associating filetypes with my application
Werner F. Bruhin
werner.bruhin at free.fr
Thu May 31 01:37:39 PDT 2007
Hi Christian,
Christian K wrote:
> simon kagwe wrote:
>
>> Hi,
>>
>> I have created an exe from a wxPython application. I some files created using
>> pickle and I want them to be opened in my application when double-clicked. Is
>> this possible?
>>
>> By the way, how can I allocate an icon to those files?
>>
>
> use python's _winreg module.
>
interesting, didn't know about this.
> e.g.
>
> import _winreg as reg
>
> reg.CreateKey(reg.HKEY_CLASSES_ROOT,'.lpj')
> reg.SetValue(reg.HKEY_CLASSES_ROOT, '.lpj', reg.REG_SZ, 'peak-o-mat')
> pom = reg.CreateKey(reg.HKEY_CLASSES_ROOT, 'peak-o-mat')
> ico = reg.CreateKey(pom, 'DefaultIcon')
> reg.SetValue(pom, 'DefaultIcon', reg.REG_SZ, iconpath)
> sh = reg.CreateKey(pom, 'shell')
> op = reg.CreateKey(sh, 'open')
> cmd = reg.CreateKey(op, 'command')
> reg.SetValue(op, 'command', reg.REG_SZ, '\"%s\" \"%%1\"'%batchpath)
>
> This will register '.lpj' file extension with an application called 'peak-o-mat'
> and assign a default icon.
>
>
Have you tested this on Vista? I think it would only work if the
application runs as admin, or it might write it to a virtualized area (I
think this depends on the manifest file you use).
Werner
More information about the wxpython-users
mailing list