From c0c6520c404ea16c3674f9ceadb46b47ba1bc673 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A1s=20Veres-Szentkir=C3=A1lyi?= Date: Tue, 5 Nov 2013 21:42:08 +0100 Subject: [PATCH] extracted function generate_png_filename --- pysstv/examples/gimp-plugin.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pysstv/examples/gimp-plugin.py b/pysstv/examples/gimp-plugin.py index 7962600..b50740a 100755 --- a/pysstv/examples/gimp-plugin.py +++ b/pysstv/examples/gimp-plugin.py @@ -133,8 +133,7 @@ class ProgressCanvas(Canvas): def transmit_current_image(image, drawable, mode, vox, fskid): sstv = MODULE_MAP[mode] - handle, png_fn = mkstemp(suffix='.png', prefix='pysstv-gimp-') - os.fdopen(handle).close() + png_fn = generate_png_filename() try: pdb.gimp_file_save(image, drawable, png_fn, png_fn) pil_img = Image.open(png_fn) @@ -166,6 +165,11 @@ def transmit_current_image(image, drawable, mode, vox, fskid): finally: os.remove(png_fn) +def generate_png_filename(): + handle, png_fn = mkstemp(suffix='.png', prefix='pysstv-gimp-') + os.fdopen(handle).close() + return png_fn + register( "pysstv_for_gimp", "PySSTV for GIMP",