[Pythonmac-SIG] SetSystemUIMode in python?
Bob Ippolito
bob at redivi.com
Fri May 27 23:51:00 CEST 2005
On May 27, 2005, at 2:24 PM, Jacob Kaplan-Moss wrote:
> I'm working on a kiosk app, and I'd like to use SetSystemUIMode and
> friends (defined in MacApplication.h inside HIToolbox.framework). As
> far as I can tell, the HIToolbox framework isn't exposed in MacPython
> anywhere, but I might be missing something.
>
> Before I start figuring out how to wrap these functions myself, am I
> right in thinking there's currently no way to get at them from
> MacPython?
With MacPython as-is, there is no way that I'm aware of... but that
doesn't mean you should write an extension.
> Also, if I do end up needing to write an extension to get at them,
> can anyone suggest the best way to go about this? Specifically, is
> Pyrex a good tool to use for wrapping Carbon APIs like this? I've not
> written an extension since I became aware of Pyrex...
While Pyrex is a pretty reasonable way to write extensions, PyObjC or
ctypes is generally less painful when wrapping a small number of
functions.
# cut + paste comments
kUIModeNormal = 0
kUIModeContentSuppressed = 1
kUIModeContentHidden = 2
kUIModeAllSuppressed = 4
kUIModeAllHidden = 3
kUIOptionAutoShowMenuBar = 1 << 0
kUIOptionDisableAppleMenu = 1 << 2
kUIOptionDisableProcessSwitch = 1 << 3
kUIOptionDisableForceQuit = 1 << 4
kUIOptionDisableSessionTerminate = 1 << 5
kUIOptionDisableHide = 1 << 6
# wrapped function
import objc
from Foundation import NSBundle
bundle = NSBundle.bundleWithPath_('/System/Library/Frameworks/
Carbon.framework')
objc.loadBundleFunctions(bundle, globals(), (
('SetSystemUIMode', 'III', " Sets the presentation mode for
system-provided user interface elements."),
))
It does work: <http://undefined.org/python/
PyInterpreter_SetSystemUIMode.png>
-bob
More information about the Pythonmac-SIG
mailing list