Installing numdifftools library
I am trying to install numdifftools library. On the python shell I've entered 'pip install numdifftools' however it is not working.
How do I install additional libraries, such as numdifftools, in the pythonista consule?
I believe Rubicon objects have an ObjCClass or objc_class attribute. Are these pyto UI objects, or standards objects?
@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
The attribute TextView of the PyTextView object is a standard UITextView.
And from pyto_ui.py:
self.__py_view__ = __PyTextView__.newView()
TextView.__py_view__.TextViewshould 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
Which are dicts that maybe live in the ObjCClass of an object. So try
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
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())
@bosco same error
dict_keys(['.cxx_destruct', 'initWithFrame', 'traitCollectionDidChange', 'initWithCoder' ])
dict_keys(['allowsEditingTextAttributes', 'setAllowsEditingTextAttributes:', 'setAttribu tedText:', 'setInputView:'])
Sorry, looking at the Rubicon code again, the
instance_methodsattribute only gets filled on demand for the methods called by Rubicon.
instance_method_ptrsshould 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 want
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.