PySimpleGUI/Demo_Button_Click.py

25 lines
894 B
Python
Raw Normal View History

import PySimpleGUI as sg
import winsound
sg.ChangeLookAndFeel('Dark')
sg.SetOptions(element_padding=(0,0))
layout = [
[sg.ReadFormButton('Start', button_color=('white', 'black'), key='start'),
sg.ReadFormButton('Stop', button_color=('white', 'black'), key='stop'),
sg.ReadFormButton('Reset', button_color=('white', 'firebrick3'), key='reset'),
sg.ReadFormButton('Submit', button_color=('white', 'springgreen4'), key='submit')]
]
2018-09-23 16:16:50 +00:00
form = sg.FlexForm("Button Click", default_element_size=(12,1), text_justification='r', auto_size_text=False, auto_size_buttons=False, default_button_element_size=(12,1)).Layout(layout).Finalize()
form.FindElement('submit').Update(disabled=True)
recording = have_data = False
while True:
button, values = form.Read()
if button is None:
exit(69)
winsound.PlaySound("ButtonClick.wav", 1)