Hi, I’m back... and yesterday i was recalling this forum, i just came by to tell you my experience.
*Now it works and was easy to solve but difficult to get it there, because it seems is some app issue. I had to close and re-open the app as if it needs to refresh all variables or objects, idk.
I noticed it when i was working on this code, it worked okay and then i took a 15mins break, but when i was back to Pythonista; it suddenly stop working... <<why?! If it was already working just fine>> Well i debugged it and i could see ‘contacts.Person()’ fields being changed and ‘saved’ correctly, BUT those updates only showed up within Pythonista, and not in My Contacts app. It was like if Pythonista retrieved all my contacts from a different app or memory.
Well, after trying changing the code here and there without any success, i just closed the app(slide up) and re-open it, and voila, my code was working again, all contacts’ updates were mirrored in my contacts app.
Now, the code i was testing and worked fine as example. (You can use get_all_people() instead of find() )
import clipboard primer_valor_de_lista = 0 curr_cb = clipboard.get() temp_contact = contacts.find('Temporal') person = temp_contact[primer_valor_de_lista] #print(person.first_name) #converted = int(curr_cb) #print(curr_cb) person.phone = [(contacts.MAIN_PHONE, curr_cb)] #temp_contact[primer_valor_de_lista]=person contacts.save() #print(person.phone) Insert Code Here
Just like you, i found Pythonista after playing around with shortcuts(workflow). It’s amazing what you can do with shortcuts and now with automation. Well i bought Pythonista, 2 years ago but i recently started using it, in fact, i bought some nfc chips, i put one in my car and what it does is,
Turn off wifi
Turn on Bluetooth (music plays via Bluetooth)
Turn on mobil data (4g)
Open app YouTube music
Play my playlist
Set brightness to 80% (from 7am to 7pm)
Set brightness to 40% (from 7pm to 6am)
Set volume to 80%
Send “coming” sms to ‘Temporal’
But the interesting part was trying to send a message to notify my boss or anyone else that I’m coming.
I created a temporal contact like everyone else does in the contact app, then i went to Pythonista and tried to read the contact ‘temporal’, edit it’s phone number and save it so that shortcuts sends the sms. Funny thing is that i can’t make it work yet because my code is not editing my temporal contacts phone number.
Anyways, first time with python.
Hello guys, it’s time for me to use this app (i bought it 2 years ago lol)
Now I’m trying to get one specific contact, i read the documentation and i could managed to get/retrieve the contact, but when i attempt to edit its phone value, it’s not saving it. Even with “contact.save()” at the end. Any help please? Thanks
import contacts import clipboard DEFAULT_CONTACT = 'Temporal' curr_cb = clipboard.get() people = contacts.get_all_people() for p in people: if p.first_name == DEFAULT_CONTACT: p.phone = [(contacts.MAIN_PHONE, int(curr_cb))] print(p.first_name + ' ' + p.phone) contacts.save() break print(p.phone) contacts.save() ```