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()
-
@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 -
@cvp
ok....I should have avoided this mistake long ago...
Just let this asynchronous function run on the main thread. Everything is normal, no flashbacks, and no errors........ -
@rozaimech Congratulations....
If not secret/confidential 😀, please share your code -
@cvp
There will be an error message:TypeError..# coding: utf-8 from objc_util import * import ui def dropInteraction_canHandleSession_(_m,_c,interaction,session): return True def dropInteraction_sessionDidUpdate_(_m,_c,interaction,session): return ObjCClass('UIDropProposal').alloc().initWithDropOperation(2).ptr def dropInteraction_performDrop_(_m,_c,interaction,session): session=ObjCInstance(session) def handler(_cmd,obj_ptr): obj=ObjCInstance(obj_ptr) print(obj) handler_block = ObjCBlock(handler, restype=None, argtypes=[c_void_p,c_void_p]) for item in session.items(): itemProvider =item.itemProvider() uiimage =ObjCClass('UIImage') nsstring =ObjCClass('NSString') if(itemProvider.canLoadObjectOfClass(uiimage)): on_main_thread(itemProvider.loadObjectOfClass_completionHandler_(ObjCClass('UIImage'),handler_block)) elif(itemProvider.canLoadObjectOfClass(nsstring)): on_main_thread(itemProvider.loadObjectOfClass_completionHandler_(nsstring,handler_block)) else: continue methods=[dropInteraction_canHandleSession_,dropInteraction_sessionDidUpdate_,dropInteraction_performDrop_] protocols=['UIDropInteractionDelegate'] dropDelegate=create_objc_class('MydropDelegate',methods=methods,protocols=protocols) Delegate=dropDelegate.alloc().init() dropInteraction=ObjCClass('UIDropInteraction').alloc().initWithDelegate(Delegate) drop_view = ui.View(bg_color='blue',frame=(0,0,500,500)) drop_view.objc_instance.setUserInteractionEnabled(True) drop_view.objc_instance.addInteraction(dropInteraction) drop_view.present()