ADDED stop hotkey (Num 9)
This commit is contained in:
parent
3b4e7b9374
commit
4aba40a327
1 changed files with 22 additions and 15 deletions
35
main.py
35
main.py
|
@ -62,17 +62,7 @@ def sound_get(filename, mode): # Сбор файлов
|
|||
exit()
|
||||
return sounds_list
|
||||
|
||||
def play_sound(index): # Проигрываение звука
|
||||
#filename = sound_get('settings.json', False)[1][index]
|
||||
filename = COMBOS[index].currentText()
|
||||
try:
|
||||
data, fs = sf.read(os.path.join('sound', filename), dtype='float32')
|
||||
sd.play(data, fs)
|
||||
sd.wait()
|
||||
except:
|
||||
pass
|
||||
|
||||
def start():
|
||||
def save(): # Сохранение списка хоткеев
|
||||
hotkeys = []
|
||||
sounds = sound_get('settings.json', False)
|
||||
for i in COMBOS:
|
||||
|
@ -81,9 +71,22 @@ def start():
|
|||
sounds = None
|
||||
hotkeys = None
|
||||
|
||||
#def sounds_explore(): # Оверлей
|
||||
# print('showing everlay')
|
||||
# overlay.show()
|
||||
|
||||
def play_sound(index): # Проигрываение звука
|
||||
filename = COMBOS[index].currentText()
|
||||
try:
|
||||
data, fs = sf.read(os.path.join('sound', filename), dtype='float32')
|
||||
sd.play(data, fs)
|
||||
keyboard.wait(sd.play())
|
||||
sd.wait()
|
||||
except:
|
||||
pass
|
||||
|
||||
###! CONTROL !###
|
||||
|
||||
def key(arg): # Хоткеи
|
||||
keyboard.add_hotkey('f1', play_sound, args=[0])
|
||||
keyboard.add_hotkey('f2', play_sound, args=[1])
|
||||
|
@ -97,12 +100,14 @@ def key(arg): # Хоткеи
|
|||
keyboard.add_hotkey('f10', play_sound, args=[9])
|
||||
keyboard.add_hotkey('f11', play_sound, args=[10])
|
||||
keyboard.add_hotkey('f12', play_sound, args=[11])
|
||||
keyboard.wait(hotkey='alt+x')
|
||||
keyboard.add_hotkey(73, sd.stop)
|
||||
#keyboard.add_hotkey('shift+f2', sounds_explore)
|
||||
keyboard.wait()
|
||||
main()
|
||||
|
||||
def main(): # Интерфейс
|
||||
win.show()
|
||||
win.start_button.setText('Save')
|
||||
win.show()
|
||||
sounds = sound_get('settings.json', True)[1]
|
||||
|
||||
combo = 0
|
||||
|
@ -114,7 +119,7 @@ def main(): # Интерфейс
|
|||
x = threading.Thread(target=key, args=(1,))
|
||||
x.setDaemon(True)
|
||||
x.start()
|
||||
win.start_button.clicked.connect(start)
|
||||
win.start_button.clicked.connect(save)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -125,6 +130,8 @@ if __name__ == '__main__':
|
|||
|
||||
app = QtWidgets.QApplication([])
|
||||
win = uic.loadUi("sundpood.ui")
|
||||
#overlay = uic.loadUi("overlay.ui")
|
||||
#overlay.setWindowFlags(QtCore.Qt.ToolTip)
|
||||
|
||||
COMBOS = [
|
||||
win.combo0,
|
||||
|
|
Loading…
Add table
Reference in a new issue