From 0347aa7a3bcec73b432fc09ab13abf8a6bf56ae9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A1s=20Veres-Szentkir=C3=A1lyi?= Date: Sun, 3 Nov 2013 22:41:11 +0100 Subject: [PATCH] added SSTV module init and buttons to GIMP plugin --- pysstv/examples/gimp-plugin.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/pysstv/examples/gimp-plugin.py b/pysstv/examples/gimp-plugin.py index 85914e3..2dc758c 100755 --- a/pysstv/examples/gimp-plugin.py +++ b/pysstv/examples/gimp-plugin.py @@ -7,23 +7,46 @@ from gimpfu import register, main, pdb, PF_BOOL, PF_STRING, PF_RADIO from tempfile import mkstemp from PIL import Image, ImageTk -from Tkinter import Tk, Label +from Tkinter import Tk, Label, Button from pysstv import __main__ as pysstv_main import os MODULE_MAP = pysstv_main.build_module_map() +class Transmitter(object): + def __init__(self, sstv, root): + self.sstv = sstv + self.root = root + + def start_tx(self, e): + pdb.gimp_message("TX!") # TODO + + def close(self, e): + self.root.destroy() + 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() try: pdb.gimp_file_save(image, drawable, png_fn, png_fn) pil_img = Image.open(png_fn) root = Tk() + s = sstv(pil_img, 44100, 16) + s.vox_enabled = vox + if fskid: + s.add_fskid_text(fskid) + tm = Transmitter(s, root) tk_img = ImageTk.PhotoImage(pil_img) img_widget = Label(root, image=tk_img) img_widget.image = tk_img img_widget.pack() + start_btn = Button(root, text="TX") + start_btn.bind('', tm.start_tx) + start_btn.pack() + close_btn = Button(root, text="Close") + close_btn.bind('', tm.close) + close_btn.pack() root.mainloop() finally: os.remove(png_fn)