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.
Containers for photos, with scroll, drag&drop between them
-
@jmv38 said:
it is much easier to wire things together via a register/trigger message system. Do you have something available?
No, never done like that. I always use normal way of ui. Good luck
-
-
@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')
-
@jmv38 Too complex for me 😀
-
@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. -
@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. -
@jmv38 did you try ui.RENDERING_MODE_ORIGINAL
-
@jmv38 this is ok, I think
img = ui.Image('iow:refresh_32')#.with_rendering_mode(ui.RENDERING_MODE_ORIGINAL) b.image = img b.tint_color = 'gray'
-
@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? -
@cvp you know what? it works with ORIGINAL
looks like omz inverted TEMPLATE and ORIGINAL values
thanks. -
@jmv38 said:
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?You asked gray and I didn't know you had a gray background
-
@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. -
@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. -
-
@jmv38 this works for me
import ui iv = ui.ImageView() iv.image = ui.Image.named('P1020096.JPG') # 3888 x 2592 pixels wi,hi = iv.image.size iv.frame = (0,0,wi,hi) print(wi,hi) # 3888 2592 w = 2*wi h = 2*hi print(w,h) # 7776 5184 with ui.ImageContext(w,h) as ctx: iv.draw_snapshot() ui_image = ctx.get_image() with open('t1.jpg', 'wb') as f: f.write(ui_image.to_jpeg(0.9)) # 15552 x 10368
-
But 9000 x 6000 crashes..
-
@cvp thank for the info
i check again -
@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.
-
@jmv38 Not interested actually, thanks. If needed, I'll create an album.
-
@jmv38 During my tests and my multiple crashes, I'm pretty sure I have seen a red message during one microsecond, containing the words Decompression Bombs
This is a [PIL message](Decompression Bombs) .
I didn't use PIL. Perhaps the ui.Image.save uses it...Something like, it not sure, message disappeared immediately
/usr/lib64/python2.6/site-packages/PIL/Image.py:2261: DecompressionBombWarning: Image size (166109750 pixels) exceeds limit of 89478485 pixels, could be decompression bomb DOS attack. DecompressionBombWarning)