Button Click Demo update
This commit is contained in:
parent
a026100ef6
commit
0d09cfcaa2
Binary file not shown.
Binary file not shown.
|
@ -3,35 +3,28 @@ import winsound
|
||||||
import sys
|
import sys
|
||||||
import PySimpleGUI as sg
|
import PySimpleGUI as sg
|
||||||
|
|
||||||
|
|
||||||
if not sys.platform.startswith('win'):
|
if not sys.platform.startswith('win'):
|
||||||
sg.popup_error('Sorry, you gotta be on Windows')
|
sg.popup_error('Sorry, you gotta be on Windows')
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
# .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'
|
||||||
|
|
||||||
# sg.change_look_and_feel('Dark')
|
sg.change_look_and_feel('Dark Blue 3') # because gray windows are boring
|
||||||
# sg.set_options(element_padding=(0,0))
|
|
||||||
|
|
||||||
layout = [
|
# Your window's layout
|
||||||
[sg.Button('Start', button_color=('white', 'black'), key='start'),
|
layout = [ [sg.Text('Click a button to hear a click')],
|
||||||
sg.Button('Stop', button_color=('white', 'black'), key='stop'),
|
[sg.Button('Click'), sg.Button('Another Click')]]
|
||||||
sg.Button('Reset', button_color=('white', 'firebrick3'), key='reset'),
|
# Create your Window
|
||||||
sg.Button('Submit', button_color=('white', 'springgreen4'), key='submit')]
|
window = sg.Window("Button Click", layout)
|
||||||
]
|
|
||||||
|
|
||||||
window = sg.Window("Button Click", layout, finalize=True,
|
while True: # The Event Loops
|
||||||
default_element_size=(12, 1), text_justification='r',
|
event, values = window.read()
|
||||||
auto_size_text=False, auto_size_buttons=False,
|
|
||||||
default_button_element_size=(12, 1), use_default_focus=False )
|
|
||||||
|
|
||||||
window['submit'].update(disabled=True)
|
|
||||||
|
|
||||||
recording = have_data = False
|
|
||||||
while True:
|
|
||||||
event, values = window.read(timeout=100)
|
|
||||||
if event is None:
|
if event is None:
|
||||||
break
|
break
|
||||||
if event != sg.TIMEOUT_KEY:
|
if event == 'Click':
|
||||||
winsound.PlaySound("ButtonClick.wav", 1)
|
winsound.PlaySound(click_sound, 1)
|
||||||
|
elif event == 'Another Click':
|
||||||
|
winsound.PlaySound(click_sound1, 1)
|
||||||
window.close()
|
window.close()
|
||||||
|
|
Loading…
Reference in New Issue