Created
September 20, 2011 16:48
-
-
Save rcarmo/1229627 to your computer and use it in GitHub Desktop.
Fullscreen webkit or PDF windows across any number of displays
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from Quartz import * | |
from AppKit import * | |
from Foundation import * | |
import WebKit | |
import objc | |
import time | |
windows = {} | |
views = {} | |
def main(): | |
app = NSApplication.sharedApplication() | |
app.setPresentationOptions_(NSApplicationPresentationAutoHideMenuBar | NSApplicationPresentationAutoHideDock) | |
NSCursor.setHiddenUntilMouseMoves_(YES) | |
screens = NSScreen.screens() | |
NSMenu.setMenuBarVisible_(False) | |
for screen in screens: | |
win = NSWindow.alloc() | |
rect = Foundation.NSMakeRect(0,0,0,0) | |
win.initWithContentRect_styleMask_backing_defer_(rect, NSBorderlessWindowMask, NSBackingStoreBuffered, False) | |
win.setFrame_display_animate_(screen.frame(), YES, YES) | |
win.makeKeyAndOrderFront_(None) | |
pdfview = PDFView.alloc() | |
pdfview.initWithFrame_(screen.frame()) | |
pdfview.setDisplayMode_(kPDFDisplaySinglePage) | |
pdfview.setDisplayBox_(kPDFDisplayBoxMediaBox) | |
pdfview.setBackgroundColor_(NSColor.blackColor()) | |
pdfview.setAutoScales_(True) | |
doc = PDFDocument.alloc() | |
docurl = NSURL.URLWithString_("file:///tmp/test.pdf") | |
doc.initWithURL_(docurl) | |
pdfview.setDocument_(doc) | |
width = screen.frame().size.width | |
height = screen.frame().size.height | |
win.setContentView_(pdfview) | |
windows[screen] = win | |
views[screen] = pdfview | |
# this is the basic mechanism for going to the next page | |
if pdfview.canGoToNextPage: | |
pdfview.goToNextPage_(None) | |
app.run() | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment