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
05c27303
Commit
05c27303
authored
Apr 18, 2021
by
Fedrico Otaran
Browse files
Agrego valor correspondiente de acuerdo al turno
parent
90619c5d
Pipeline
#244
failed with stages
in 0 seconds
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
src/component/board.py
View file @
05c27303
import
PySimpleGUI
as
sg
from
itertools
import
cycle
from
src.windows
import
board
...
...
@@ -8,7 +9,13 @@ def start():
def
loop
():
window
=
board
.
build
(
"Fede"
,
"Milka"
)
player_1
=
{
"name"
:
"Maria"
,
"value"
:
"X"
}
player_2
=
{
"name"
:
"Marta"
,
"value"
:
"O"
}
turn
=
cycle
([
player_1
,
player_2
])
board_data
=
[[
" "
]
*
3
for
_i
in
range
(
3
)]
window
=
board
.
build
(
player_1
,
player_2
,
board_data
)
while
True
:
event
,
_values
=
window
.
read
()
...
...
@@ -17,7 +24,7 @@ def loop():
break
if
event
.
startswith
(
"cell"
):
_prefix
,
x
,
y
=
event
.
split
(
"-"
)
print
(
f
"Celda:
{
x
}
,
{
y
}
"
)
player
=
next
(
turn
)
window
[
event
].
update
(
player
[
"value"
]
)
return
window
src/windows/board.py
View file @
05c27303
import
PySimpleGUI
as
sg
def
build
(
player1_name
,
player2_name
):
def
build
(
player_1
,
player_2
,
board_data
):
layout
=
[
[
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
(
"
Jugador 1:
"
+
player_
1
[
"
name
"
]
,
key
=
"
-P1-
"
,
text_color
=
"
darkblue
"
)],
[
sg
.
Text
(
"
Jugador 2:
"
+
player_
2
[
"
name
"
]
,
key
=
"
-P2-
"
,
text_color
=
"
white
"
)],
[
sg
.
Text
(
""
)]
,
]
for
y
in
range
(
3
):
layout
+=
[
[
sg
.
Button
(
' '
,
size
=
(
8
,
4
),
key
=
f
"cell-
{
x
}
-
{
y
}
"
)
for
x
in
range
(
3
)]
[
sg
.
Button
(
board_data
[
x
][
y
],
size
=
(
8
,
4
),
key
=
f
"cell-
{
x
}
-
{
y
}
"
)
for
x
in
range
(
3
)
]
]
board
=
sg
.
Window
(
'
Ta Te Ti
'
).
Layout
(
layout
)
board
=
sg
.
Window
(
"
Ta Te Ti
"
).
Layout
(
layout
)
return
board
\ No newline at end of file
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