46 lines
1.3 KiB
Python
46 lines
1.3 KiB
Python
|
import PySimpleGUI as sg
|
||
|
import glob
|
||
|
import offitracker as offi
|
||
|
import sys
|
||
|
import csv
|
||
|
import numpy as np
|
||
|
import sounddevice as sd
|
||
|
import threading
|
||
|
|
||
|
names = glob.glob("./**/*.csv", recursive=True)
|
||
|
toplay = ""
|
||
|
|
||
|
layout = [[sg.Text('Search')],
|
||
|
[sg.Input(size=(200, 1), enable_events=True, key='-INPUT-')],
|
||
|
[sg.Listbox(names, size=(200, 10), enable_events=True, key='-LIST-')],
|
||
|
[sg.Button('Play'), sg.Button('Stop'), sg.Text("",key="file")]]
|
||
|
|
||
|
window = sg.Window('OffiPlayer', layout,size=(480, 320))
|
||
|
|
||
|
def playthread(window):
|
||
|
offi.stop_signal = False
|
||
|
offi.play_csv_file(toplay)
|
||
|
window.write_event_value(('-THREAD-', '** DONE **'), 'Done!')
|
||
|
|
||
|
while True:
|
||
|
event, values = window.read()
|
||
|
if event in (sg.WIN_CLOSED, 'Exit'):
|
||
|
break
|
||
|
if values['-INPUT-'] != '':
|
||
|
search = values['-INPUT-']
|
||
|
new_values = [x for x in names if search in x]
|
||
|
window['-LIST-'].update(new_values)
|
||
|
else:
|
||
|
window['-LIST-'].update(names)
|
||
|
if event == '-LIST-' and len(values['-LIST-']):
|
||
|
toplay = values['-LIST-'][0]
|
||
|
window['file'].update(toplay)
|
||
|
if event == 'Play':
|
||
|
window.start_thread(lambda: playthread(window), ('-THREAD-', '-THEAD ENDED-'))
|
||
|
if event == 'Stop':
|
||
|
offi.stop_signal = True
|
||
|
window.close()
|
||
|
|
||
|
|
||
|
|