View Single Post
Old 03-09-2014, 10:34 PM   #4
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,359
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Code:
from calibre.ptempfile import TemporaryDirectory

with TemporaryDirectory('xxx') as tdir:
   for x in ('one.jpg', 'two.jpg'):
      with open(os.path.join(tdir, x) as f:
         f.write(get_resources('images/' + x))
    about.exec_()
It is important to note that you should exec your dialog inside the outermost with block as the temp dir will be deleted when you exit the with block.
kovidgoyal is offline   Reply With Quote