Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
python2021
Code
ps_gui_example
Commits
b5bc5b15
Commit
b5bc5b15
authored
May 31, 2021
by
Fedrico Otaran
Browse files
Agrego timer usado en la explicación de main loop
parent
756da7f6
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/component/board.py
View file @
b5bc5b15
import
PySimpleGUI
as
sg
import
time
as
t
from
itertools
import
cycle
from
src.windows
import
board
from
src.handlers
import
board
as
board_handler
...
...
@@ -24,8 +25,11 @@ def loop():
window
=
board
.
build
(
player_1
,
player_2
,
board_data
)
start_time
=
t
.
time
()
counter
=
0
while
True
:
event
,
_values
=
window
.
read
()
print
(
"-- read"
)
event
,
_values
=
window
.
read
(
timeout
=
100
)
if
event
in
(
sg
.
WINDOW_CLOSED
,
"Exit"
,
"-exit-"
):
break
...
...
@@ -38,4 +42,14 @@ def loop():
sg
.
popup
(
f
"¡Felicitaciones! Ha ganado
{
player
[
'name'
]
}
"
)
break
counter
+=
1
window
[
"-SIMPLE_TIMER-"
].
update
(
f
"
{
counter
//
60
:
02
d
}
:
{
counter
%
60
:
02
d
}
"
)
print
(
f
"-- counter
{
counter
}
"
)
current_time
=
t
.
time
()
-
start_time
window
[
"-TIMER-"
].
update
(
f
"
{
round
(
current_time
//
60
):
02
d
}
:
{
round
(
current_time
%
60
):
02
d
}
"
)
window
.
refresh
()
return
window
src/windows/board.py
View file @
b5bc5b15
...
...
@@ -9,6 +9,23 @@ def build(player_1, player_2, board_data):
[
sg
.
Text
(
"Jugador 1: "
+
player_1
[
"name"
],
key
=
"-P1-"
,
text_color
=
"darkblue"
)],
[
sg
.
Text
(
"Jugador 2: "
+
player_2
[
"name"
],
key
=
"-P2-"
,
text_color
=
"white"
)],
[
sg
.
Text
(
""
)],
[
sg
.
Text
(
""
,
size
=
(
8
,
2
),
font
=
(
"Helvetica"
,
20
),
justification
=
"center"
,
key
=
"-SIMPLE_TIMER-"
,
),
sg
.
Text
(
""
,
size
=
(
8
,
2
),
font
=
(
"Helvetica"
,
20
),
justification
=
"center"
,
key
=
"-TIMER-"
,
),
],
[
sg
.
Button
(
"Next"
,
key
=
"-NEXT-"
)],
]
for
y
in
range
(
3
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment