added Stop button to GIMP plugin

ironpython
András Veres-Szentkirályi 2013-11-04 15:08:24 +01:00
rodzic d09a88540d
commit b5ba501ad0
1 zmienionych plików z 24 dodań i 1 usunięć

Wyświetl plik

@ -10,21 +10,41 @@ from PIL import Image, ImageTk
from Tkinter import Tk, Label, Button
from pysstv import __main__ as pysstv_main
from pysstv.examples.pyaudio_sstv import PyAudioSSTV
from threading import Thread
import os
MODULE_MAP = pysstv_main.build_module_map()
class AudioThread(Thread):
def __init__(self, sstv):
Thread.__init__(self)
self.pas = PyAudioSSTV(sstv)
def run(self):
self.pas.execute()
def stop(self):
self.pas.sampler = []
class Transmitter(object):
def __init__(self, sstv, root):
self.sstv = sstv
self.root = root
self.audio_thread = None
def start_tx(self, e):
PyAudioSSTV(self.sstv).execute()
self.audio_thread = AudioThread(self.sstv)
self.audio_thread.start()
def stop_tx(self, e):
if self.audio_thread is not None:
self.audio_thread.stop()
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-')
@ -45,6 +65,9 @@ def transmit_current_image(image, drawable, mode, vox, fskid):
start_btn = Button(root, text="TX")
start_btn.bind('<Button-1>', tm.start_tx)
start_btn.pack()
start_btn = Button(root, text="Stop")
start_btn.bind('<Button-1>', tm.stop_tx)
start_btn.pack()
close_btn = Button(root, text="Close")
close_btn.bind('<Button-1>', tm.close)
close_btn.pack()