如何解决使用 PyObjC 以 NSWindow 的风格初始化 NSPanel
我从 PyObjC 文档中下载了其中一个示例代码,并将其去除了大部分非必要内容。然后我将 NSWindow 的所有引用更改为 NSPanel,但这没有任何效果。
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()
我无法让这个窗口成为 HUD NSPanel,它保持正常 NSWindow 的形式。
其次,似乎 win.orderFrongRegardless()
不能正常工作,因为我必须在运行代码后从 Dock 手动打开窗口。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。