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?
Generally, pure python modules can be installed using pip in stash
However, despite numpy and matplotlib coming with pythonista, you cannot install other c/fortran packages like scipy, pandas, etc.
Numdifftools appears to require scipy, which means it probably won't work.
As others have stated, the app pyto is open source and does support scipy, however it's user interface apparently leaves a lot to be desired.
however it's user interface apparently leaves a lot to be desired.
Believe me, not only the user interface.
For the fun, I try to convert a very small part of my outline program, but I meet a lot of limitations, for instance you don't have access to methods of ObjcInstance of an ui.Control...
@cvp really? I have never really used pyto, but it looked to me that the pyto_ui module was a thin wrapper around UIKit using rubicon objc. ObjCInstance might work a little differently -- you might need to find the object or pointer to pass into ObjCInstance, since the Rubicon version might not automatically look for the _objc_instance or .ptr attribute.
It looks like there should be a py_view_ attribute of pyto Views, which might be the ObjCInstance directly?
@JonB I was in the Pyto Discord discussion group and I asked help for this problem and a smart guy answered to use
tv = pyto_ui.textView("some text...") tv_objc = ObjCInstance(tv.__py_view__.managed) print(tv_objc.objc_class.instance_methods)
He said: "Right, I think because rubicon implements a wrapper of the UITextView (UIView, etc) with some kind of limitations. The limited exposed methods though, I think, they are due to Pyto'simplementation."
but that gives some attributes but not (all?) methods like in Pythonista.
So I was not able, for instance, to use Attributes or bring_to_front and so on.
Unfortunately, it seems that the developer never answers herself to questions/bugs.
Edit: it seems that setAttributedText is also a method of TextField.ObjectiveC
Édit: and of TextView. setAllowsEditingTextAttributes: and setAttributedText: seem to be the only two existing methods
For TextField, I've been able to display it coloured via attributes, and also for TextView
I have also been able to use setInputView_ even if this method is not in the list of methods....nor dir
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.