[Pythonmac-SIG] Best way to do full-screen mode?

Bob Ippolito bob at redivi.com
Sat Jul 22 01:44:24 CEST 2006

On Jul 21, 2006, at 3:39 PM, David Warde-Farley wrote:

> On 21-Jul-06, at 6:26 PM, Robert Stephenson wrote:
>> My app needs a full-screen mode, and am looking for examples or
>> advice how to do it.  CoreGraphics allows you to capture the
>> display and then draw on it, but since it's not written in ObjC my
>> understanding is that it's not easily accessible from PyObjC.  An
>> alternative would be to bring up a borderless full-screen window.
>> Can that be done easily?
> I know that Pygame can do this fairly easily on other platforms.
> Given that it's all a wrapper on top of SDL it should work on the Mac
> as well. (Can anyone confirm?)

Yes, pygame does work full screen, but you need to use SDL to draw in  
that case.

That subset of CoreGraphics should be easy enough to talk to from  
ctypes or PyObjC's FFI capability...

import objc
from Foundation import NSBundle
bndl = NSBundle.bundleWithPath_(objc.pathForFramework 
# this is cheating, CGDirectDisplayID is a pointer, but we treat it  
as an int
     ('CGMainDisplayID', 'i'),
     ('CGDisplayCapture', 'ii'),
     ('CGDisplayRelease', 'ii'),
objc.loadBundleFunctions(bndl, globals(), FUNCTIONS)

Those functions should be all you need to jack into full-screen. With  
ctypes it would be a bit different...

from ctypes import c_void_p, cdll, c_int
from ctypes.util import find_library

# again cheating, return value and arguments all default to int
# so we don't need to bother setting argtype/restype
_dylib = cdll.LoadLibrary(find_library('ApplicationServices'))
CGMainDisplayID = _dylib.CGMainDisplayID
CGDisplayCapture = _dylib.CGDisplayCapture
CGDisplayRelease = _dylib.CGDisplayRelease


More information about the Pythonmac-SIG mailing list