@omz said:
@zenz Too much complicated, mostly, but I think I'll get to it eventually.
Hi @omz!
Itβs two years later β any progress/updates for us about pandas, seaborn? π³
Pythonista 4 anywhere on the horizon?
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.
@omz said:
@zenz Too much complicated, mostly, but I think I'll get to it eventually.
Hi @omz!
Itβs two years later β any progress/updates for us about pandas, seaborn? π³
Pythonista 4 anywhere on the horizon?
@Phuket2 Hi, Iβm on the beta program, too, and will have a look at this library! Thanks for the hint! π
@JonB Awesome, that did the trick! Iβm glad my code works now exactly as I wanted it to work! π Thanks so much for that missing puzzle piece!!
Hi,
I have a date as a string in the form βdd/mm/yyyyβ and need to convert it to the form βdd. MMMM yyyyβ so that the verbose month is printed out in German.
Now, because we still have the locale bug in Pythonista ...
>>> import locale
>>> locale.setlocale(locale.LC_ALL, 'de')
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/var/containers/Bundle/Application/4D653312-79ED-4473-B63A-522E9EA8C250/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/locale.py", line 599, in setlocale
return _setlocale(category, locale)
locale.Error: unsupported locale setting
>>> locale.setlocale(locale.LC_ALL, 'de_DE')
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/var/containers/Bundle/Application/4D653312-79ED-4473-B63A-522E9EA8C250/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/locale.py", line 599, in setlocale
return _setlocale(category, locale)
locale.Error: unsupported locale setting
... I guess Iβm forced to find a workaround. So I opted for the objc_util
module and tried this (variable gebDatum
holds the initial date string in the above mentioned format):
from objc_util import *
NSDateFormatter = ObjCClass('NSDateFormatter')
dateFormatter = NSDateFormatter.alloc().init()
NSLocale = ObjCClass('NSLocale')
deLocale = NSLocale.alloc().initWithLocaleIdentifier_(ns('de'))
dateFormatter.setLocale_(deLocale)
NSDate = ObjCClass('NSDate')
date = NSDate.alloc().init()
dateFormatter.setDateFormat_('dd/MM/yyyy')
date = dateFormatter.dateFromString_(gebDatum)
dateFormatter.setDateFormat_('dd. MMMM yyyy')
gebDatumVerbose = dateFormatter.stringFromDate_(date)
Now when I want to print out the variable gebDatumVerbose
I get the error must be str, not ObjCInstance
.
Any help / hint / explanation / other (shorter) solution for my problem?
Thanks a lot!
Stefan.
@omz Thanks again, Ole! Works perfectly, time stamp is now correct. π
A bit off-topic extra question: is it possible to launch Photos, go to the album I created and show the image I saved?
@omz WOW!
Never ever would I've been able to write such a line like you did in the try
statment! I have no idea why & how this syntax works, that remains as a brain teaser for the weekend! π
Thanks so much for this quick help, Ole!! SO much appreciated! (Just a mini error: the parameter in the create_image_asset()
call has to be image_path
. π
However, I discovered a time stamp problem: I just saved an image to an album. When I did this the time was 03.03.2017, 20:07. When I launched the Photos app and opened my album I saw the one image in it but Photos said the image was dated from yesterday (02.03.2017) and from 22:12 ... π€
Anyone any idea why this might be the case (and how to fix it)?
Hi,
I'd like to kindly ask for a few lines of sample code. I want to achieve this:
I have a custom ui.View where I draw things to.
I want to save the contents of this view as a PNG to my own, new album inside the device's Photos library.
The next time the user wants to save an image it should go into the β now existing β album.
So I assume it goes like this:
Questions:
Being still a Python starter it would be great if someone could help!
Thanks a lot!
Stefan.
Aweseom hints, guys! Didn't know about the dialogs module at all. The dialogs.list_dialog()
looks good and suits my needs. π
Thanks a lot!!
Got a ui View.
It contains a TableView and nothing else.
The view gets presented via present('sheet')
.
Immediately after presenting it I wait via wait_modal()
.
Now the user should tap on one item in the TableView and the view should close.
The closing of the view works (tableview.superview.close()
) but I don't know how to transport the information about the tapped row back to the main thread so that I can work with it after the wait_modal()
returns ...?
This is my delegate (with debug output):
class MyTableViewDelegate (object):
def tableview_did_select(self, tableview, section, row):
# Called when a row was selected.
print("tableview_did_select: row=", row)
print(tableview.data_source.items[row])
tableview.superview.close()
pass
Any help regarding how to get the tableview.data_source.items[row]
information out of this delegate method back to my main program would be awesome! π
Guys,
still a beginner at Python, so please be patient.
I'm using the twitter.request function for a Twitter API request.
The result is a tuple consisting of a return code and the actual JSON result.
I want to get hold of that JSON result like this:
if status == 200:
result = json.loads(data)
However, I get this error:
Traceback (most recent call last):
File "/private/var/mobile/Containers/Shared/AppGroup/9D2704E0-434A-4879-8FB0-30594FA3A28D/Pythonista3/Documents/addToCollectionIK.py", line 17, in <module>
result = json.loads(data)
File "/var/containers/Bundle/Application/B09EF8B7-CE0F-4572-9748-EC15615DEA7A/Pythonista3.app/Frameworks/PythonistaKit3.framework/pylib/json/init.py", line 312, in loads
s.class.name))
TypeError: the JSON object must be str, not 'bytes'
Why is that and what can I do about it? From what I understand the twitter.request function doesn't seem to return the JSON object as a string but as 'bytes' (what's that?). So I need to make a string out of that bytes, right? But how?
(btw, the json.load(data) function doesn't work, either ...)
Thanks a lot,
Stefan.
It's not possible to write Python scripts in Editorial's editor.
So if I need to write a module and import it in a Python action in a workflow β how would I achieve this?
Please don't let the answer be "You cant!"
Thanks so much,
Stefan.
Hi,
in the UI editor of a Python script action I created a ScrollView and inside that ScrollView I embedded an ImageView.
At design time I have to set the dimensions of that image view. Currently it's the default square (200x200).
Via the Image URL property I loaded a non-square image that's displayed distorted now because the view want to make both, the width & the height to fit.
Is there a way to tell the IamgeView not to squeeze my non-square image into the square view?
I want to add several more ImageViews later and they all should be square but the actual images won't be square most of the time.
Thanks,
Stefan.
Oh! I found something!
Looks like I have to set the property content_mode
of the ImageView.
Like this:
view.subviews[0].subviews[0].content_mode = ui.CONTENT_SCALE_ASPECT_FIT
I can't find this property in the UI editor. So I have to set it at run time?