omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    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.


    Edit a contact iOS

    Pythonista
    python 3.6 pythonista contacts
    4
    5
    3025
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • 3ryck
      3ryck last edited by 3ryck

      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[0] = [(contacts.MAIN_PHONE, int(curr_cb))]
         	print(p.first_name + ' ' + p.phone[0][1])
         	contacts.save()
         	break
      print(p.phone)
      contacts.save() ```
      cvp LenaCharles 2 Replies Last reply Reply Quote 0
      • JonB
        JonB last edited by

        https://github.com/omz/Pythonista-Issues/issues/205
        Might be related?

        Have you tried opening contacts to see if your update show up there? It may be that it just doesn't get updated within pythonista..

        1 Reply Last reply Reply Quote 0
        • cvp
          cvp @3ryck last edited by cvp

          @3ryck that does not solve the problem (save does not work), but I think (perhaps erroneously) that

          1. telephone n° (curr_cb) is a string, not an int
          2. p.phone[0] is a tuple, not an array of tuples (p.phone is an array)
                 p.phone[0] = (p.phone[0][0],curr_cb) 
          
          1 Reply Last reply Reply Quote 0
          • LenaCharles
            LenaCharles @3ryck last edited by

            This post is deleted!
            1 Reply Last reply Reply Quote 0
            • 3ryck
              3ryck last edited by 3ryck

              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[0]) 
              Insert Code Here
              
              1 Reply Last reply Reply Quote 1
              • First post
                Last post
              Powered by NodeBB Forums | Contributors