2018-09-27 20:24:09 +00:00
|
|
|
#!/usr/bin/env python
|
2019-10-23 20:10:03 +00:00
|
|
|
import winsound
|
2018-09-24 22:01:00 +00:00
|
|
|
import sys
|
2019-10-23 20:10:03 +00:00
|
|
|
import PySimpleGUI as sg
|
|
|
|
|
2018-10-21 17:18:05 +00:00
|
|
|
if not sys.platform.startswith('win'):
|
2019-10-23 20:10:03 +00:00
|
|
|
sg.popup_error('Sorry, you gotta be on Windows')
|
|
|
|
sys.exit(0)
|
2018-09-27 20:24:09 +00:00
|
|
|
|
2019-11-27 22:19:31 +00:00
|
|
|
# .WAV files that contain your click sounds. Put full path if not in your application's folder
|
|
|
|
click_sound = r'ButtonClick.wav'
|
|
|
|
click_sound1 = r'ButtonClick1.wav'
|
2018-09-14 16:17:19 +00:00
|
|
|
|
2019-11-27 22:19:31 +00:00
|
|
|
sg.change_look_and_feel('Dark Blue 3') # because gray windows are boring
|
2018-09-14 16:17:19 +00:00
|
|
|
|
2019-11-27 22:19:31 +00:00
|
|
|
# Your window's layout
|
|
|
|
layout = [ [sg.Text('Click a button to hear a click')],
|
|
|
|
[sg.Button('Click'), sg.Button('Another Click')]]
|
|
|
|
# Create your Window
|
|
|
|
window = sg.Window("Button Click", layout)
|
2018-09-14 16:17:19 +00:00
|
|
|
|
2019-11-27 22:19:31 +00:00
|
|
|
while True: # The Event Loops
|
|
|
|
event, values = window.read()
|
2018-10-15 20:07:23 +00:00
|
|
|
if event is None:
|
2019-10-23 20:10:03 +00:00
|
|
|
break
|
2019-11-27 22:19:31 +00:00
|
|
|
if event == 'Click':
|
|
|
|
winsound.PlaySound(click_sound, 1)
|
|
|
|
elif event == 'Another Click':
|
|
|
|
winsound.PlaySound(click_sound1, 1)
|
2019-10-23 20:10:03 +00:00
|
|
|
window.close()
|