NSPanel initializing in the style of NSWindow using PyObjC

161 views Asked by At

I downloaded one of the example codes from the PyObjC Documentation and stripped it down of most of its non-essential contents. I then changed all references of NSWindow to NSPanel, but this had no effect.

from Cocoa import NSObject, NSApplication, NSApp, NSWindow, NSButton, NSSound, NSPanel
from PyObjCTools import AppHelper

def main():
    NSApplication.sharedApplication()

    # we must keep a reference to the delegate object ourselves,
    # NSApp.setDelegate_() doesn't retain it. A local variable is
    # enough here.
    delegate = NSPanel.alloc().init()
    NSApp().setDelegate_(delegate)

    win = NSPanel.alloc()
    frame = ((200.0, 700.0), (100.0, 100.0))
    win.initWithContentRect_styleMask_backing_defer_(frame, 15, 2, 0)
    win.setLevel_(3)  # floating window
    win.display()
    win.orderFrontRegardless()  # but this one does

    AppHelper.runEventLoop()

if __name__ == "__main__":
    main()

I can't get this Window to be an HUD NSPanel, it stays in the form of a normal NSWindow. Secondly, it seems that win.orderFrongRegardless() doesn't work properly, since I have to manually open the Window from my Dock after running the Code.

0

There are 0 answers