• jmv38

    yes, it was a bug from me, the function works fine
    thanks

    posted in Pythonista read more
  • jmv38

    wait, maybe my bad .. i’ll check again and report.
    thanks.

    posted in Pythonista read more
  • jmv38

    AssetCollection.remove_assets() seems to work only with the albums created during the same run. If I use it in a later run, nothing happens, although AssetCollection.can_remove_assets is True, and no error is raised.
    Any idea on how to have this work? I am making a fast album editor, and this kind of ruins my project... 😢
    Thanks!

    posted in Pythonista read more
  • jmv38

    Sounds amazing! But what langage does it use for coding?

    posted in Pythonista read more
  • jmv38

    @cvp you are correct. My pb was pbly sthg else.

    posted in Pythonista read more
  • jmv38

    @cvp just to let you know here is my code.
    It wont run because the rest of the code is missing, but it gives you the idea

    def save(self):
        # make a hi resolution copy of back & images, then save it in camera roll
        xo, yo, w, h = self.page.back.frame
        c = self.page.back.background_color
        targetWidth = 4*1024
        s = targetWidth / w
        w, h = w*s, h*s
        page = ui.View( frame=(0,0,w,h), background_color=c)
        views = []
        for thumb in self.thumbs:
          x,y,w,h = thumb.frame
          x,y,w,h = (x-xo)*s, (y-yo)*s, w*s, h*s
          v = ui.View( frame=(x,y,w,h) )
          x,y,w,h = thumb.iv.frame
          x,y,w,h = x*s, y*s, w*s, h*s
          img = thumb.getImage(thumb.asset)
          iv = ui.ImageView(frame=(x,y,w,h), image=img)
          v.add_subview(iv)
          page.add_subview(v)
          views.append(v)
        # save page image in pythonista
        getTopView().add_subview(page)
        #page.bring_to_front()
        #if True: return
        path = 'temp.jpg'
        with ui.ImageContext(page.width, page.height) as ctx:
          page.draw_snapshot()                            
          ui_image = ctx.get_image()
        pil = Image.open(io.BytesIO(ui_image.to_png()))
        pil.save(path , quality=99)
        # save page image in albums
        asset = photos.create_image_asset(path)
        os.remove(path)
        getTopView().remove_subview(page)
        views = False
        console.hud_alert('saved')
    

    looks like i must add the view to the screen to get the draw snapshot to work.

    posted in Pythonista read more
  • jmv38

    @cvp i do have 2 pixels per point (ipad air)
    i dont crash, it is just that the image saved is black
    i checked that 4x1024 is ok and 4x1025 fails
    i remember this ios limit 4096 from somwhere.

    posted in Pythonista read more
  • jmv38

    @cvp 5000 doesnt work for me and 5000<7000

    posted in Pythonista read more
  • jmv38

    @cvp i had forgotten that 4000 is really 8000 because x2
    i think 8000 should be enough for prints 60 cm wide => thanks. you saved my last week of coding!

    However it is strange that 15000 is ok bu not 9000...?

    Concerning the use of the project without any album, i could modify this for you if you are really interested in using this code. Are you?

    thanks.

    posted in Pythonista read more
  • jmv38

    @cvp thank for the info
    i check again

    posted in Pythonista read more
  • jmv38

    @cvp hello again!

    I am trying to make a high definition image with draw_snapshot()
    I works fine until the context width is 4000, but i get a black image when the context width is 5000 or more. I need 9000....
    Any suggestion?
    Thanks.

    posted in Pythonista read more
  • jmv38

    @cvp actually it does work on the regular version.
    Not sure why i didnt see that before.
    Thanks.

    posted in Pythonista read more
  • jmv38

    @cvp thank you!
    when you say:

    Altough last version of Pythonista offers an easy way to add an home screen shortcut for an edited script

    do you mean the first link above?

    posted in Pythonista read more
  • jmv38

    @shinyformica hello!
    how do you make a homescreen shortcut to a pythonista script?
    thanks!

    posted in Pythonista read more
  • jmv38

    @cvp i have finished my first version of the program
    here https://gist.github.com/1b67ba85ca7bd7b23c7058216895372c
    this will:

    • let you choose an album xxxx
    • load the 200 first pictures
    • present them in a photopicker
    • from which you can build photo album pages (collage)
    • it creates 2 new albums:
    • xxxx_pages : the album pages
    • xxxx_pages_and_photos: as it says. useful to upload the album in photoweb printing service for instance
    • your own photos and albums are not modified

    to see how to use it tap ‘?’ button: it opens a youtube video that shows it in action.

    It is designed to work in lanscape mode
    let me know how it works for you.

    posted in Pythonista read more
  • jmv38

    @cvp you know what? it works with ORIGINAL
    looks like omz inverted TEMPLATE and ORIGINAL values
    thanks.

    posted in Pythonista read more
  • jmv38

    @cvp thanks.
    but it still doesnt work: now the button shows in gray, not white, and is not visible on my gray background.
    I wonder how to get it simply as it shows in the editor?

    posted in Pythonista read more
  • jmv38

    @cvp i am in the final polishing phase of my project.
    I have pb with button icons: they render in color when i want a gray rendering (the one shown in the editor).
    my code:

    img = ui.Image('iow:refresh_32').with_rendering_mode(ui.RENDERING_MODE_TEMPLATE)
        clear_button.image = img
    

    any suggestion?
    thanks.

    posted in Pythonista read more
  • jmv38

    @cvp i can understand what you feel: it is exactly what i thought the first time saw this! It took me several months to start to understand it, but once i did, bam!, it opened a huge box of possibilties because it made a complex project so much simpler. But I wont try to convert you, you’ll see for yourself as i use it in my project if you think it is usefull...
    Thanks.

    posted in Pythonista read more
  • jmv38

    @cvp here an example of a very simple event class i found on google and modified for my needs. I also added an example of usage.

    class EventHook(object):
    
        def __init__(self):
            self.__handlers = []
    
        def __iadd__(self, handler):
            self.__handlers.append(handler)
            return self
    
        def __isub__(self, handler):
            self.__handlers.remove(handler)
            return self
    
        def __call__(self, *args, **keywargs):
            for handler in self.__handlers:
                handler(*args, **keywargs)
    
        def clearObjectHandlers(self, inObject):
            for theHandler in self.__handlers:
                if theHandler.im_self == inObject:
                    self -= theHandler
                    
    if __name__ == '__main__':
      class Watcher():
          def __init__(self):
              self.incoming = EventHook()
              self.leaving = EventHook()
      
      class Greeter():
        def __init__(self,me):
          self.me = me
        def sayHello(self, name):
          print('{}: hello Mister {}'.format(self.me,name))
        def sayGoodbye(self, name):
          print('{}: goobye Mister {}'.format(self.me,name))
          
      class Maid():
        def __init__(self,me):
          self.me = me
        def sayHello(self, name):
          print('{}: hello Mister {}'.format(self.me,name))
        def sayGoodbye(self, name):
          if name != 'DSK':
            print('{}: goobye Mister {}'.format(self.me,name))
          else:
            print('{}: You f... s.. o. a b...!'.format(self.me))
      
      from console import clear
      clear()
      Isee = Watcher()
      deskMan = Greeter('desk man Georges')
      maid = Maid('maid Sandra')
      
      # make the connections:
      Isee.incoming += lambda name: print('\nM. {} is comming...'.format(name))
      Isee.incoming += deskMan.sayHello
      Isee.incoming += maid.sayHello
      
      Isee.leaving += lambda name: print('\nM. {} is leaving...'.format(name))
      Isee.leaving += maid.sayGoodbye
      Isee.leaving += deskMan.sayGoodbye
      
      # remove listener from the event
      
      # fire event
      Isee.incoming('Clinton')
      Isee.leaving('Clinton')
    
      
    

    posted in Pythonista read more
Internal error.

Oops! Looks like something went wrong!