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

Michael Hudson mwh at python.net
Sat Jul 22 12:01:20 CEST 2006


Robert Stephenson <rstephe at alumni.princeton.edu> writes:

> An alternative would be to bring up a borderless full-screen window.
> Can that be done easily?

I don't know about easily, but it's doable form PyObjC.  Hacked out
from somewhere else:

class PQFullScreenWindow(NSWindow):

    def makeForView_(cls, view):
        screen = NSScreen.mainScreen()
        self = cls.alloc().initWithContentRect_styleMask_backing_defer_(
            screen.frame(), NSBorderlessWindowMask, NSBackingStoreBuffered, True)
        self.view = view
        return self
    makeForView_ = classmethod(makeForView_)


    def canBecomeKeyWindow(self):
        return True


    def resignKeyWindow(self):
        super(PQFullScreenWindow, self).resignKeyWindow()
        if self.view.fullscreen > 0:
            self.view.toggleFullScreen_(self)


class PQView:
    def awakeFromNib(self):
        ...
        self.fsw = PQFullScreenWindow.makeForView_(self)


    def toggleFullScreen_(self, sender):
        ...
        # some mucking about with contentViews, etc
            self.fsw.makeKeyAndOrderFront_(self)
            self.fsw.makeFirstResponder_(self)
            self.fsw.setLevel_(NSPopUpMenuWindowLevel)

HTH,
mwh

-- 
  > Touche! But this confirms you are composed of logic gates.
  Crud, I thought those were neurons in there.
                    -- Thomas F. Burdick, Kenny Tilton, comp.lang.lisp


More information about the Pythonmac-SIG mailing list