Added import code for BOTH 2.,7 and 3
This commit is contained in:
parent
8b4185988f
commit
ab98ea20eb
66 changed files with 1284 additions and 136 deletions
|
@ -1,5 +1,10 @@
|
|||
import PySimpleGUI as sg
|
||||
#!/usr/bin/env python
|
||||
import sys
|
||||
if sys.version_info[0] < 3:
|
||||
import PySimpleGUI27 as sg
|
||||
else:
|
||||
import PySimpleGUI as sg
|
||||
|
||||
"""
|
||||
Demonstrates using a "tight" layout with a Dark theme.
|
||||
Shows how button states can be controlled by a user application. The program manages the disabled/enabled
|
||||
|
@ -15,15 +20,15 @@ layout = [[sg.T('User:', pad=((3,0),0)), sg.OptionMenu(values = ('User 1', 'User
|
|||
[sg.ReadButton('Start', button_color=('white', 'black'), key='Start'),
|
||||
sg.ReadButton('Stop', button_color=('white', 'black'), key='Stop'),
|
||||
sg.ReadButton('Reset', button_color=('white', 'firebrick3'), key='Reset'),
|
||||
sg.ReadButton('Submit', button_color=('white', 'springgreen4'), key='Submit')]
|
||||
]
|
||||
sg.ReadButton('Submit', button_color=('white', 'springgreen4'), key='Submit')]]
|
||||
|
||||
window = sg.Window("Time Tracker", default_element_size=(12,1), text_justification='r', auto_size_text=False, auto_size_buttons=False,
|
||||
default_button_element_size=(12,1)).Layout(layout)
|
||||
window.Finalize()
|
||||
window.FindElement('Stop').Update(disabled=True)
|
||||
window.FindElement('Reset').Update(disabled=True)
|
||||
window.FindElement('Submit').Update(disabled=True)
|
||||
default_button_element_size=(12,1)).Layout(layout).Finalize()
|
||||
|
||||
|
||||
for key, state in {'Start': False, 'Stop': True, 'Reset': True, 'Submit': True}.items():
|
||||
window.FindElement(key).Update(disabled=state)
|
||||
|
||||
recording = have_data = False
|
||||
while True:
|
||||
button, values = window.Read()
|
||||
|
@ -31,27 +36,17 @@ while True:
|
|||
if button is None:
|
||||
sys.exit(69)
|
||||
if button is 'Start':
|
||||
window.FindElement('Start').Update(disabled=True)
|
||||
window.FindElement('Stop').Update(disabled=False)
|
||||
window.FindElement('Reset').Update(disabled=False)
|
||||
window.FindElement('Submit').Update(disabled=True)
|
||||
for key, state in {'Start':True, 'Stop':False, 'Reset':False, 'Submit':True}.items():
|
||||
window.FindElement(key).Update(disabled=state)
|
||||
recording = True
|
||||
elif button is 'Stop' and recording:
|
||||
window.FindElement('Stop').Update(disabled=True)
|
||||
window.FindElement('Start').Update(disabled=False)
|
||||
window.FindElement('Submit').Update(disabled=False)
|
||||
[window.FindElement(key).Update(disabled=value) for key,value in {'Start':False, 'Stop':True, 'Reset':False, 'Submit':False}.items()]
|
||||
recording = False
|
||||
have_data = True
|
||||
elif button is 'Reset':
|
||||
window.FindElement('Stop').Update(disabled=True)
|
||||
window.FindElement('Start').Update(disabled=False)
|
||||
window.FindElement('Submit').Update(disabled=True)
|
||||
window.FindElement('Reset').Update(disabled=False)
|
||||
[window.FindElement(key).Update(disabled=value) for key,value in {'Start':False, 'Stop':True, 'Reset':True, 'Submit':True}.items()]
|
||||
recording = False
|
||||
have_data = False
|
||||
elif button is 'Submit' and have_data:
|
||||
window.FindElement('Stop').Update(disabled=True)
|
||||
window.FindElement('Start').Update(disabled=False)
|
||||
window.FindElement('Submit').Update(disabled=True)
|
||||
window.FindElement('Reset').Update(disabled=False)
|
||||
[window.FindElement(key).Update(disabled=value) for key,value in {'Start':False, 'Stop':True, 'Reset':True, 'Submit':False}.items()]
|
||||
recording = False
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue