내가 디자인하고있는 응용 프로그램에 NSOpenPanel을 사용하고 싶습니다. 여기에 지금까지이 작업은 다음과 같습니다PyObjC 선택기에서 void 포인터를 어떻게 표현합니까?
@objc.IBAction
def ShowOpenPanel_(self, sender):
self.panel = NSOpenPanel.openPanel()
self.panel.setCanChooseFiles_(False)
self.panel.setCanChooseDirectories_(True)
NSLog(u'Starting OpenPanel')
self.panel.beginForDirectory_file_types_modelessDelegate_didEndSelector_contextInfo_(
self.defaults.objectForKey_(u'projpath'),
objc.nil,
objc.nil,
self,
objc.selector(self.OpenPanelDidEnd_returnCode_contextInfo_,
signature='v:@ii'),
objc.nil)
NSLog(u'OpenPanel was started.')
def OpenPanelDidEnd_returnCode_contextInfo_(self, panel, returnCode, context):
NSLog('Panel ended.')
if (returnCode == NSOKButton):
NSLog(u'User selected OK')
path = self.panel.filenames()[0]
self.defaults.setObject_forKey_(path, u'projpath')
del self.panel
나에 대해 걱정 주요 두 줄은 다음과 같습니다
objc.selector(self.OpenPanelDidEnd_returnCode_contextInfo_,
signature='v:@ii'),
objc.nil) #this is the argument that gets passed as the void pointer
세 번째 인수는 무효 포인터 있어야한다. 그 데이터를 사용하지 않으려 고하기 때문에 비워 두는 편이 낫습니다. 나는 'v:@iv'
이라는 시그니처를 만들려고 노력했으며 objc.NULL
과 파이썬의 None
을 사용해 보았다. 이것을 처리하는 가장 좋은 방법은 무엇입니까?
감사합니다. 이번 주말에 사용해 보겠습니다. –