FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
PySimpleGUI/DemoPrograms/Demo_Button_States.py at master · PySimpleGUI/PySimpleGUI · GitHub
PySimpleGUI
/
PySimpleGUI
Public
Notifications
You must be signed in to change notification settings
Fork
1.8k
Star
13.8k
Code
Issues
708
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
PySimpleGUI
/
DemoPrograms
/
Demo_Button_States.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
64 lines (53 loc) · 2.61 KB
Breadcrumbs
PySimpleGUI
/
DemoPrograms
/
Demo_Button_States.py
Copy path
File metadata and controls
64 lines (53 loc) · 2.61 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env python
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
states for buttons and changes the text color to show greyed-out (disabled) buttons
Copyright 2018-2026 PySimpleGUI. All rights reserved.
"""
sg
.
theme
(
'Dark'
)
sg
.
set_options
(
element_padding
=
(
0
,
0
))
layout
=
[[
sg
.
Text
(
'User:'
,
pad
=
((
3
,
0
),
0
)),
sg
.
OptionMenu
(
values
=
(
'User 1'
,
'User 2'
),
size
=
(
20
,
1
)),
sg
.
Text
(
'0'
,
size
=
(
8
,
1
))],
[
sg
.
Text
(
'Customer:'
,
pad
=
((
3
,
0
),
0
)),
sg
.
OptionMenu
(
values
=
(
'Customer 1'
,
'Customer 2'
),
size
=
(
20
,
1
)),
sg
.
Text
(
'1'
,
size
=
(
8
,
1
))],
[
sg
.
Text
(
'Notes:'
,
pad
=
((
3
,
0
),
0
)),
sg
.
Input
(
size
=
(
44
,
1
),
background_color
=
'white'
,
text_color
=
'black'
)],
[
sg
.
Button
(
'Start'
,
button_color
=
(
'white'
,
'black'
),
key
=
'-Start-'
),
sg
.
Button
(
'Stop'
,
button_color
=
(
'white'
,
'black'
),
key
=
'-Stop-'
),
sg
.
Button
(
'Reset'
,
button_color
=
(
'white'
,
'firebrick3'
),
key
=
'-Reset-'
),
sg
.
Button
(
'Submit'
,
button_color
=
(
'white'
,
'springgreen4'
),
key
=
'-Submit-'
)]]
window
=
sg
.
Window
(
"Time Tracker"
,
layout
,
default_element_size
=
(
12
,
1
),
text_justification
=
'r'
,
auto_size_text
=
False
,
auto_size_buttons
=
False
,
default_button_element_size
=
(
12
,
1
),
finalize
=
True
)
for
key
,
state
in
{
'-Start-'
:
False
,
'-Stop-'
:
True
,
'-Reset-'
:
True
,
'-Submit-'
:
True
}.
items
():
window
[
key
].
update
(
disabled
=
state
)
recording
=
have_data
=
False
while
True
:
event
,
values
=
window
.
read
()
print
(
event
)
if
event
==
sg
.
WIN_CLOSED
:
break
if
event
==
'-Start-'
:
for
key
,
state
in
{
'-Start-'
:
True
,
'-Stop-'
:
False
,
'-Reset-'
:
False
,
'-Submit-'
:
True
}.
items
():
window
[
key
].
update
(
disabled
=
state
)
recording
=
True
elif
event
==
'-Stop-'
and
recording
:
[
window
[
key
].
update
(
disabled
=
value
)
for
key
,
value
in
{
'-Start-'
:
False
,
'-Stop-'
:
True
,
'-Reset-'
:
False
,
'-Submit-'
:
False
}.
items
()]
recording
=
False
have_data
=
True
elif
event
==
'-Reset-'
:
[
window
[
key
].
update
(
disabled
=
value
)
for
key
,
value
in
{
'-Start-'
:
False
,
'-Stop-'
:
True
,
'-Reset-'
:
True
,
'-Submit-'
:
True
}.
items
()]
recording
=
False
have_data
=
False
elif
event
==
'-Submit-'
and
have_data
:
[
window
[
key
].
update
(
disabled
=
value
)
for
key
,
value
in
{
'-Start-'
:
False
,
'-Stop-'
:
True
,
'-Reset-'
:
True
,
'-Submit-'
:
False
}.
items
()]
recording
=
False
window
.
close
()
Back
|
FazBrowse Home
|
New Git URL