0

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.

  • 1
    That style mask isn't specifying a HUD - something like `NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskHUDWindow` would be 8195. – red_menace Apr 29 '21 at 15:36
  • @red_menace Thanks a lot, is there some sort of list, that shows the different styles? I would never come to the number 8195. – Yassine Elshayeb Apr 29 '21 at 20:15
  • 1
    The [NSWindow](https://developer.apple.com/documentation/appkit/nswindow?language=objc) documentation. Specifically, the `styleMask` parameter of the `initWithContentRect:styleMask:backing:defer:` method uses the [NSWindowStyleMask](https://developer.apple.com/documentation/appkit/nswindowstylemask?language=objc) enumerations. You can `or` the various constants or add the integer equivalents to get the mask. – red_menace Apr 29 '21 at 21:26

0 Answers0