Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Problems when using objc_util()
-
@rozaimech I'be done a step more but not yet ok
def dropInteraction_performDrop_(_m,_c,interaction,session): session=ObjCInstance(session) print('dropInteraction_performDrop_ called') '''object c: [session loadObjectsOfClass:[NSString class] completion:^(NSArray<__kindof id<NSItemProviderReading>> * _Nonnull objects) { self.dropLabel.text = objects.firstObject;}]; ''' def handler(_cmd):#,obj1_ptr,_error): print('block called') handler_block = ObjCBlock(handler, restype=None, argtypes=[c_void_p])#, c_void_p, c_void_p]) for item in session.items(): print(item) itemProvider = item.itemProvider() print(itemProvider) ret = itemProvider.loadObjectsOfClass_completion_(NSString, handler_block)
-
@rozaimech we will win, I hope.
You did a small error in loadObjectOfClass_completionHandler_def dropInteraction_performDrop_(_m,_c,interaction,session): session=ObjCInstance(session) print('dropInteraction_performDrop_ called') '''object c: [session loadObjectsOfClass:[NSString class] completion:^(NSArray<__kindof id<NSItemProviderReading>> * _Nonnull objects) { self.dropLabel.text = objects.firstObject;}]; ''' def handler(_cmd,obj1_ptr,_error): print('block called') obj1 = ObjCInstance(obj1_ptr) print(obj1) handler_block = ObjCBlock(handler, restype=None, argtypes=[c_void_p, c_void_p, c_void_p]) for item in session.items(): print(item) itemProvider = item.itemProvider() print(itemProvider) #print(dir(itemProvider)) itemProvider.loadObjectOfClass_completionHandler_(NSString, handler_block)
-
@rozaimech I don't know what you want to drop.
I try with a photo (with the Photos app in split view with Pythonista) and, if you comment the print(obj1) line,- we see that the dropped item is a public.jpeg
- the block is called
Up to here, it is ok but there is still work (for you?) th analyze the droped item. I've tried but not yet solved...
-
@cvp
I made a program to synchronize the clipboard of PC and iPad, but it can only run in pythonista. If I use drop and drag, I can realize the clipboard of iPad (pythonista runs as a window) -
-
@cvp
I haven't used objc_util too much before in pythonista, and I have learned a lot recently, including the pythonista pointer you told me, the syntax of Object C, and the current problem is that I'm not familiar with the use of block as a parameter. Next, I will continue to study it -
@rozaimech said:
I can realize the clipboard of iPad
sorry,it's mean “can realize the global clipboard of iPad”
-
@rozaimech I'm sincerely sorry, perhaps due to my poor English, but I can't understand this "realize"
-
@cvp
I should have misused my words..
realize..
implements..
implementation ...
implementation function? xd -
@rozaimech do you know the
clipboard
Pythonista module? -
@rozaimech If you only want to drop a text in a Pythonista script, you don't need Objectivec, you can drop any text in a ui.TextField
-
-
@rozaimech Nice, seriously
-
@zrzka wrote a drag script
-
This post is deleted! -
@rozaimech, good to note that the view you attach the drag on must be
touch_enabled
. Just spent a while wondering why my Label is not happening... -
@cvp
drag already written
and drop already written, too
but Random crashes have no error log -
@rozaimech did you install @dgelessus ´s log as adviced by @jonb in a previous post of this topic? And is it a _objc_exception.txt file in the root?
-
@cvp
The first call successfully gets the dragged data, but the second flash back. I'm trying to resolve this error.The error log isFatal Python error: Segmentation fault Thread 0x000000016fc77000 (most recent call first):
-
@rozaimech I got it more than ten times during my tests for trying to help you. I didn't find the reason.
If you change the code of a delegate method, restart Pythonista, that helps often