Yep, that was it restyle s/b restype
The problem with “cut and paste” programming is that I don’t know enough about what I’m seeing to see the obvious. In this case I should have “cut and paste” one more time, and it would have given me no trouble.
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.
Yep, that was it restyle s/b restype
The problem with “cut and paste” programming is that I don’t know enough about what I’m seeing to see the obvious. In this case I should have “cut and paste” one more time, and it would have given me no trouble.
I am working on a project using a MapView based on @jsbain "Map View Demo2.py" jsbain github
I am adding a set of anotations that I getting from Open Street Maps (OSM) and that requires that I first limit to a geographical range.
In order to do that, I need to know that lat/long range of the display.
'get_center_coordinate()' works great for "where" I am but to get limit the range I need to know the "span" of the mapview.
I thought that it would be easy to just copy the code from get_center_coordinate() to create get_region() (see below) but my code causes an error; "No method found for region"
The Apple documentation MKMapView shows that 'centerCoordinate' only differs from 'region' in the return type ('CLLocationCoordinate2D' vs 'MKCoordinateRegion'
My understanding of objective C is poor at best and so is nderstanding of the objc_util module.
Any help I can get whether it be a hint or actual working code would be appreciated.
*This method works great
def get_center_coordinate(self):
"""Return the current center coordinate as a (latitude, longitude) tuple"""
coordinate = self.mk_map_view.centerCoordinate(restype=CLLocationCoordinate2D, argtypes=[])
return coordinate.latitude, coordinate.longitude
This method errors: "No method found for region"
@on_main_thread
def get_region(self):
"""Return latitude /longitude of the view's center and the zoom level (specified implicitly as a latitude/longitude delta)"""
region = self.mk_map_view.region(restyle=MKCoordinateRegion,argtypes=[])
return region.center.latitude, region.center.longitude, region.span.d_lat, region.span.d_lon
'''
That did the trick.
selfupdate was successfull.
"pip install pythonista-gestures" installed the first time.
StaSh v0.7.2 on python 3.6.1
pythonista V. 3.4 (330025)
iphone 6S+
iOS 13.3.1
StaSh "selfupdate" returns "Already at latest version"
I've tried this over the last couple of days. Restarted Pythonista, rebooted iphone, etc. with the same result.
I tried pip install again with the above "extras", no joy, results below.
wget from the site-packages directory worked fine.
time to play with my new ̶t̶o̶y̶s̶ tools
[~/Documents]$ stashconf py_traceback 1
[~/Documents]$ stashconf py_pdb 1
[~/Documents]$ pip --verbose install pythonista-gestures
Querying PyPI ...
Using pythonista-gestures==1.0...
A binary distribution is available and will be used.
Downloading package ...
Opening: https://files.pythonhosted.org/packages/e0/76/e1766485ab9b521d9d4c304854f479b87db6df350dc54996aa5c71e4d608/pythonista_gestures-1.0-py2.py3-none-any.whl
Save as: /private/var/mobile/Containers/Data/Application/1596E9F5-6DC7-4159-8555-9611A7AEB2A8/tmp//pythonista_gestures-1.0-py2.py3-none-any.whl (10408 bytes)
10408 [100.00%]
Installing wheel: pythonista_gestures-1.0-py2.py3-none-any.whl...
Extracting wheel..
Extraction finished, running handlers...
Running handler 'WHEEL information checker'...
Wheel generated by: flit 2.2.0
Running handler 'dependency handler'...
Cleaning up...
<class 'UnicodeDecodeError'>: 'ascii' codec can't decode byte 0xe2 in position 1125: ordinal not in range(128)
Traceback (most recent call last):
File "/private/var/mobile/Containers/Shared/AppGroup/16663993-01D5-4358-99D0-C11426AFFF9B/Pythonista3/Documents/site-packages/stash/system/shruntime.py", line 547, in exec_py_file
exec(code, namespace, namespace)
File "site-packages/stash/bin/pip.py", line 1492, in <module>
repository.install(pkg_name, ver_spec, dist=dist)
File "site-packages/stash/bin/pip.py", line 1085, in install
self._install(pkg_name, pkg_info, archive_filename, dependency_dist=dist)
File "site-packages/stash/bin/pip.py", line 849, in _install
files_installed, dependencies = wheel.install(self.site_packages)
File "/private/var/mobile/Containers/Shared/AppGroup/16663993-01D5-4358-99D0-C11426AFFF9B/Pythonista3/Documents/site-packages/stash/lib/stashutils/wheels.py", line 385, in install
tfi = handler.handle_install(tp, targetdir)
File "/private/var/mobile/Containers/Shared/AppGroup/16663993-01D5-4358-99D0-C11426AFFF9B/Pythonista3/Documents/site-packages/stash/lib/stashutils/wheels.py", line 286, in handle_install
dependencies = self.read_dependencies_from_METADATA(metadatap)
File "/private/var/mobile/Containers/Shared/AppGroup/16663993-01D5-4358-99D0-C11426AFFF9B/Pythonista3/Documents/site-packages/stash/lib/stashutils/wheels.py", line 310, in read_dependencies_from_METADATA
for line in fin:
File "/var/containers/Bundle/Application/FC2E1425-424E-4F22-88E8-DDBC98DBC701/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/encodings/ascii.py", line 27, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 1125: ordinal not in range(128)
> /var/containers/Bundle/Application/FC2E1425-424E-4F22-88E8-DDBC98DBC701/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/encodings/ascii.py(27)decode()
-> return codecs.ascii_decode(input, self.errors)[0]
(Pdb)
This looks great! But I can't seem to get the install to work. This is what I get:
pip install pythonista-gestures
Querying PyPI ...
Downloading package ...
Opening: https://files.pythonhosted.org/packages/e0/76/e1766485ab9b521d9d4c304854f479b87db6df350dc54996aa5c71e4d608/pythonista_gestures-1.0-py2.py3-none-any.whl
Save as: /private/var/mobile/Containers/Data/Application/1596E9F5-6DC7-4159-8555-9611A7AEB2A8/tmp//pythonista_gestures-1.0-py2.py3-none-any.whl (10408 bytes)
10408 [100.00%]
Installing wheel: pythonista_gestures-1.0-py2.py3-none-any.whl...
<class 'UnicodeDecodeError'>: 'ascii' codec can't decode byte 0xe2 in position 1125: ordinal not in range(128)