Lately I stumbled upon a nice proggy called RocketDock. It creates an OS-X-a-like dock on Windows. Sure, it's mostly an eye-candy, which I'm not a big fan of, but it was free and seemed quite interesting so I gave it a try.
It turned out to by a really decent piece of software. Quite basic but small and lightning fast at the same time. That was an advantage for me since I hate it when background programs eat too much resources.
Of course as a programmer, I was attracted by the docklets feature. Docklets are small plugins that let a dock icon do some magic stuff not possible in normal ways. RocketDock uses the ObjectDock docklets format. An ObjectDock docklet is basically a DLL library. The library exports some functions that are called by the dock on various occasions. It can control the icon using the HWND provided by the dock and a couple of special routines.
As a Python fan, my first question was of course how to create a docklet using Python? Right, it isn't simple. There's no easy way to produce a DLL in Python. The best solution I came up with was to write a DLL using C and interface it to Python using its Python/C API. The idea was to write a single DLL that could be reused without any change for every future Python docklet.
It took me two days but the goal was achieved. My first Python docklet, which you can see on the picture, is a battery meter for my ThinkPad. Yes, not too original but one of its advantages is that it reads the battery status using IBM's drivers instead of Windows default ones which (according to IBM) makes the indications more accurate. It uses a (Windows only) "thinkpad" Python module I wrote some time ago which provides access to ThinkPads battery information, hotkeys and Active Protection System.
It took me another day to fine tune the library. The current version has full support for multithreading and can handle many Python docklets at once. It consists of two DLLs, the first one, "pydocklets.dll", is a master library, common for all docklets written in Python. The other one, "pydocklet.dll", must be duplicated for every docklet. Download the template docklet and read its docstring to learn more.
Download:
pydocklet_ThinkPadPower.zip - a docklet showing the battery status of a ThinkPad notebook; details in the docstring.
pydocklet_template.zip - a ready to use template for a new docklet; just download, drop into an apropriate docklets directory and start playing with Python; Python 2.5.x required; DLLs included.
pydocklet_src.zip - source of the DLLs; you may need this if, for example, you need a version for Python different than 2.5.x.
Distributed under the BSD license.
Update 5.05.2008:
All files have been updated and are fully compatible with ObjectDock too (previous versions were tested with RocketDock only). A new version of ThinkPadPower docklet now supports changing of the active power scheme.
Update 20.05.2008:
All files have been updated. The DLLs now emulate the events missing when using RocketDock (double-click and left-button-held). ThinkPadPower can control ThinkLight, brightness, volume and APS too. Some bugs fixed.
Subscribe to:
Post Comments (Atom)
2 Comments:
Thank you so much for your effort. I attempted to get the source, as I was hoping to learn how you did this, and I get a Site Unavailable error, at least that is what the German translates to. BTW, much more advance than my 2 years of High School German.
Sorry, the source URL was wrong, now it's fixed.
That site unavailable error was indeed kind of strange, looked a bit like if it came out of an automatic translator :).
Have fun with the source and please post back if you have any questions.
Post a Comment