python中panel不接受参数_10.6中PyObjC中openPanelDidEnd的问题

正如elv所指出的,beginSheetForDirectory:file:modalForWindow:modalDelegate:didEndSelector:contextInfo:在10.6中已经被弃用,要使用的新方法是beginSheetModalForWindow:completionHandler:在雪豹附带的PyObjC版本中没有这个方法的元数据,但是它已经被添加了,您可以自己更新适当的文件,以便可以使用这个方法。开放式/系统/库/框架/Python.framework/Versions/2.6/Extras/lib/python/PyObjC/AppKit/PyObjC.bridgesupport找到元素:

在其中添加以下内容:

^{pr2}$

这是Python端需要的元数据,以便获取正确类型的对象并将其返回给Objective-C。您可以传递完成处理程序的任何可调用项,只要它具有正确的签名(即,接受整数参数,不返回任何内容)。例如:def showOpenPanel_(self, sender):

openPanel = NSOpenPanel.openPanel()

def openPanelDidClose_(result):

if result == NSFileHandlingPanelOKButton:

openPanel.orderOut_(self)

image = NSImage.alloc().initWithContentsOfFile_(openPanel.filename())

self.imgView.setImage_(image)

openPanel.setAllowedFileTypes_(NSImage.imageFileTypes())

openPanel.beginSheetModalForWindow_completionHandler_(self.imgView.window(),

objc.selector(openPanelDidClose_, argumentTypes='l'))

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值