开发者

How do I use python wx:Config to access the Windows registry?

I've read http://wxpython.org/docs/api/wx.ConfigBase-class.html

I've done some basi开发者_运维问答c things like the appended. What I can see is that Config.Create() returns me some sort of configuration object, which has information about python in it. But clearly that's not what I'm looking for: I seem to be missing the magic to say "give me a Config that is the Windows Registry"...

Thanks!

GaJ

>>> import wx
>>> from wx import Config
>>> app=wx.App(False)
>>> config=Config.Create()
>>> config.HasGroup("HKEY_CURRENT_USER")
False
>>> config.GetFirstEntry()
(0, u'', -1)
>>> config.GetFirstGroup()
(1, u'PythonCore', 1)
>>> config.GetNextGroup(1)
(0, u'', -1)
>>> config.GetNumberOfGroups()
1
>>> config.GetPath()
u''
>>> config.HasEntry("PythonCore")
False
>>> config.GetFirstGroup()
(1, u'PythonCore', 1)


The Config classes are not intended to be used as a general purpose access path to the registry. Instead it just facilitates storing and retrieving your application's preferences data, in the way that is appropriate for the platform. In other words, it will always use a root location of something like:

HKCU/Software/VendorName/AppName/

assuming that the VendorName and AppName have been set on your wx.App object. If you want to access anything else in the registry then you'll need to use some other module to do it, as has already been mentioned.


I usually use Python builtin _winreg module for all my Registry work. Tim Golden's WMI module is also useful and you can use PyWin32 as well, but I think _winreg is the easiest unless you need to do a recursive delete.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜