Skip to content

Instantly share code, notes, and snippets.

@tgck
Created August 20, 2012 16:22
Show Gist options
  • Save tgck/3405485 to your computer and use it in GitHub Desktop.
Save tgck/3405485 to your computer and use it in GitHub Desktop.
simple window initialization in PyObjC (python)
# simple window initialization in PyObjC
import objc
from AppKit import *
from Foundation import *
from PyObjCTools import AppHelper
app = NSApplication.sharedApplication()
size = NSMakeRect(0.0, 0.0, 400.0, 400.0) # left-end-pos, bottom-end-pos, width, height
window = NSWindow.alloc().initWithContentRect_styleMask_backing_defer_(size,NSTitledWindowMask | NSClosableWindowMask |NSResizableWindowMask | NSMiniaturizableWindowMask, NSBackingStoreBuffered,False)
window.setLevel_(3)
window.contentView()
window.display()
window.orderFrontRegardless()
AppHelper.runEventLoop()
@tgck
Copy link
Author

tgck commented May 17, 2013

window.setIgnoresMouseEvents_(YES) #マウスに反応しないウィンドウ
window.setLevel_(-2147483628) # -2147483628 = kCGDesktopWindowLevel -5
→ デスクトップアイコンと壁紙の中間にウィンドウを配置
※この状態でScreenSaverEngine -background すると、当ウィンドウもスクリーンセーバに置き換えられることから、すでに壁紙の領域のもよう

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment