2013-11-03 21:04:42 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- encoding: utf-8 -*-
|
|
|
|
|
|
|
|
# copy to ~/.gimp-2.8/plug-ins/
|
|
|
|
# dependencies: GIMP 2.8, python-imaging-tk
|
|
|
|
|
2013-11-03 21:29:21 +00:00
|
|
|
from gimpfu import register, main, pdb, PF_BOOL, PF_STRING, PF_RADIO
|
2013-11-03 21:04:42 +00:00
|
|
|
from tempfile import mkstemp
|
|
|
|
from PIL import Image, ImageTk
|
2013-11-03 21:41:11 +00:00
|
|
|
from Tkinter import Tk, Label, Button
|
2013-11-03 21:29:21 +00:00
|
|
|
from pysstv import __main__ as pysstv_main
|
2013-11-04 13:33:11 +00:00
|
|
|
from pysstv.examples.pyaudio_sstv import PyAudioSSTV
|
2013-11-03 21:04:42 +00:00
|
|
|
import os
|
|
|
|
|
2013-11-03 21:29:21 +00:00
|
|
|
MODULE_MAP = pysstv_main.build_module_map()
|
|
|
|
|
2013-11-03 21:41:11 +00:00
|
|
|
class Transmitter(object):
|
|
|
|
def __init__(self, sstv, root):
|
|
|
|
self.sstv = sstv
|
|
|
|
self.root = root
|
|
|
|
|
|
|
|
def start_tx(self, e):
|
2013-11-04 13:33:11 +00:00
|
|
|
PyAudioSSTV(self.sstv).execute()
|
2013-11-03 21:41:11 +00:00
|
|
|
|
|
|
|
def close(self, e):
|
|
|
|
self.root.destroy()
|
|
|
|
|
2013-11-03 21:29:21 +00:00
|
|
|
def transmit_current_image(image, drawable, mode, vox, fskid):
|
2013-11-03 21:41:11 +00:00
|
|
|
sstv = MODULE_MAP[mode]
|
2013-11-03 21:04:42 +00:00
|
|
|
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()
|
2013-11-03 21:41:11 +00:00
|
|
|
s = sstv(pil_img, 44100, 16)
|
|
|
|
s.vox_enabled = vox
|
|
|
|
if fskid:
|
|
|
|
s.add_fskid_text(fskid)
|
|
|
|
tm = Transmitter(s, root)
|
2013-11-03 21:04:42 +00:00
|
|
|
tk_img = ImageTk.PhotoImage(pil_img)
|
|
|
|
img_widget = Label(root, image=tk_img)
|
|
|
|
img_widget.image = tk_img
|
|
|
|
img_widget.pack()
|
2013-11-03 21:41:11 +00:00
|
|
|
start_btn = Button(root, text="TX")
|
|
|
|
start_btn.bind('<Button-1>', tm.start_tx)
|
|
|
|
start_btn.pack()
|
|
|
|
close_btn = Button(root, text="Close")
|
|
|
|
close_btn.bind('<Button-1>', tm.close)
|
|
|
|
close_btn.pack()
|
2013-11-03 21:04:42 +00:00
|
|
|
root.mainloop()
|
|
|
|
finally:
|
|
|
|
os.remove(png_fn)
|
|
|
|
|
|
|
|
register(
|
|
|
|
"pysstv_for_gimp",
|
|
|
|
"PySSTV for GIMP",
|
|
|
|
"Transmits the current image using PySSTV",
|
|
|
|
"Andras Veres-Szentkiralyi",
|
|
|
|
"Andras Veres-Szentkiralyi",
|
|
|
|
"November 2013",
|
|
|
|
"<Image>/PySSTV/Transmit...",
|
|
|
|
"*",
|
2013-11-03 21:29:21 +00:00
|
|
|
[
|
|
|
|
(PF_RADIO, "mode", "SSTV mode", "MartinM1",
|
|
|
|
tuple((n, n) for n in sorted(MODULE_MAP.iterkeys()))),
|
|
|
|
(PF_BOOL, "vox", "Include VOX tones", True),
|
|
|
|
(PF_STRING, "fskid", "FSK ID", ""),
|
|
|
|
],
|
2013-11-03 21:04:42 +00:00
|
|
|
[],
|
|
|
|
transmit_current_image
|
|
|
|
)
|
|
|
|
|
|
|
|
main()
|