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.
Installing numdifftools library
-
@JonB yes Rubicon has Objcclass and I can create real ObjectiveC objects like in Pythonista, for example
NSMutableAttributedString=ObjCClass('NSMutableAttributedString') attrtext = NSMutableAttributedString.alloc() color = ObjCClass('UIColor').colorWithRed_green_blue_alpha_(1, 0, 10, 1)
But Pyto objects,like Pyto_ui.TextField are Pyto objects and it is not so easy as in Pythonista to use their methods because their list is not given by a dir. But I'm confident because I think all standard methods are available without to be sure by advance, I have to try each time. And differently of Pythonista, attributes may not be "called ", like
tfo.inputAssistantItem.setLeadingBarButtonGroups(None) Instead of tfo.inputAssistantItem().setLeadingBarButtonGroups(None) In Pythonista
-
Yes:
The attribute TextView of the PyTextView object is a standard UITextView.
And from pyto_ui.py:
self.__py_view__ = __PyTextView__.newView()
So
TextView.__py_view__.TextView
should give you the Rubicon ObjCInstance of the UITextView.Or, you might need to import rubicon.objc and call ObjCInstance on the result?
Looking at Rubicon's ObjCInstance, it doesn't expose the methods and properties via dir, I don't think. But, you can find them in
'instance_methods': 'instance_properties':
Which are dicts that maybe live in the ObjCClass of an object. So try
print(Your_pyto_textview.__py_view__.TextView.objc_class.instance_methods.keys())
-
@JonB said:
instance_methods
I had tried that but it gave only two methods, not all I have used after.... But, actually, all methods I need (until now) are accepted even if not listed in instance_methods.
Thanks for your appreciated help, as usual
-
@JonB said:
print(Your_pyto_textview.py_view.TextView.objc_class.instance_methods.keys())
For info
Traceback (most recent call last): File "iCloud/Outline/TextField Attributes.py", line 71, in <module> print(Your_pyto_textview.__py_view__.TextView.objc_class.instance_methods.keys()) File "Pyto.app/Lib/rubicon/objc/api.py", line 651, in __getattr__ raise AttributeError( AttributeError: rubicon.objc.api.ObjCInstance Pyto.PyTextView has no attribute TextView >>> ```
-
@cvp you might need to call _load_methods on the object.
-
@JonB Thanks, I'll remember if I meet problems (if I continue this process of conversion to Pyto).
-
@cvp try this: print(Your_pyto_textview.py_view.TextView.objc_class.partial_methods.keys())
-
fixed underscore
Your_pyto_textview.__py_view__.TextView.objc_class.partial_methods.keys())
-
@bosco same error
-
print(text_field.__py_view__.managed.objc_class.partial_methods.keys())
Gives
dict_keys(['.cxx_destruct', 'initWithFrame', 'traitCollectionDidChange', 'initWithCoder' ])
print(text_field.__py_view__.managed.objc_class.instance_methods.keys())
Gives
dict_keys(['allowsEditingTextAttributes', 'setAllowsEditingTextAttributes:', 'setAttribu tedText:', 'setInputView:'])
-
Sorry, looking at the Rubicon code again, the
instance_methods
attribute only gets filled on demand for the methods called by Rubicon.
But theinstance_method_ptrs
should be filled whenever you try to access any methods in the class. (Or after_load_methods()
is called on the objc class object, once. That might not be needed, not sure). Again, you wantinstance_method_ptrs.keys()
.jb
-
@JonB said:
instance_method_ptrs.keys().
print(text_field.__py_view__.managed.objc_class.instance_method_ptrs.keys())
Gives
dict_keys(['.cxx_destruct', 'initWithFrame:textContainer:', 'traitCollectionDidChange:', 'initWithCoder:'])
But anyway, don't worry, I'll each try if the method I want to use is accepted or not.