I know this is a long shot, but I was wondering if Python had a way to manipulate the screen buffer. Specifically, I want to be able to gray-out my desktop and highlight my windows when I press a key combination. Is this in the realm of possibility?
-
2In what OS do you want to do that? – sanmai Nov 14 '09 at 15:56
-
2You won't achieve that by accessing a "screen buffer", you'll have to work with an API, be that the on provided with PyQt (more generic for all platforms), .NET with IronPython (Windows), ... Accessing screen buffer directly is a notion that disappeared long ago ;-) – RedGlyph Nov 14 '09 at 16:16
-
I'm looking to deploy the application on Windows, OSX, or Linux. I suppose it being Python isn't necessarily requisite, but it is what I am most familiar with. – directedition Nov 14 '09 at 22:04
-
You're going to be using a lot of different platform-specific code with a three-pronged deployment like that -- I don't think Python is your best bet here. Cocoa on OS X, Win32/.NET on Windows, and a whole bunch of choices on Linux. – Jed Smith Nov 15 '09 at 00:52
2 Answers
From your question and the comments that followed, PyQt would be a good choice, you would have a common code for the three platforms.
You have to develop it as a GUI though, using the library functions, it also means you will have to rethink what you exactly want in terms of GUI possibilities, and in a way that respects the usual GUI conventions: users probably don't want your application to modify their favourite desktop background or to behave weirdly.
For example, there is a way to bring your application to the foreground (the examples given in answer are in C++ but equivalent methods are available in Python and the code would be very similar).
Qt is originally a C++ framework, recently acquired by Nokia, if you are also familiar with that language you should think it over before deciding which to choose, but in any case PyQt will not let you down, it is quite mature and stable.
Regarding the license, in case it's one of your concerns, PyQt is GPL and a commercial license is also available. Another Python Qt porting is in the works with a LGPL license, pushed by Nokia following the refusal from the PyQt author to change their license: PySide, but it is still in its early development.
Finally, I have to mention that Qt isn't the only GUI framework for Python, by searching you will find other questions related to that topic on SO, with other suggestions:
Instead of "graying out" the desktop, try to overlay a gray, semi-transparent image over the entire screen and then make sure your window is on top of that. You may face a couple of minor limitations; for example, I don't know off the top of my head if it's possible to overlay the mac menubar (and I'm not sure you'd want to).

- 370,779
- 53
- 539
- 685