Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Coding Week Gol Dolleans Boujerfaoui
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Boujerfaoui Yassine
Coding Week Gol Dolleans Boujerfaoui
Commits
714726e4
Commit
714726e4
authored
6 years ago
by
Dolleans Geoffrey
Browse files
Options
Downloads
Patches
Plain Diff
tkinter 1/many
parent
b8184db2
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
game_of_life/AffichageTkinter.py
+23
-7
23 additions, 7 deletions
game_of_life/AffichageTkinter.py
with
23 additions
and
7 deletions
game_of_life/AffichageTkinter.py
+
23
−
7
View file @
714726e4
from
tkinter
import
*
from
game_of_life.generate_universe
import
*
from
game_of_life.generation
import
*
from
game_of_life.survival
import
*
fenetre
=
Tk
()
game_of_life
=
Toplevel
(
fenetre
)
...
...
@@ -10,21 +11,36 @@ canvas = Canvas(game_of_life)
canvas
.
pack
()
def
create_a_grid
():
"
create the grid for the graphic interface
"
""
"
create the grid for the graphic interface
"
""
width
=
game_of_life
.
winfo_width
()
heigth
=
game_of_life
.
winfo_height
()
global
zones
#contient l'ensemble des zones representant des cellules
zones
=
[]
for
x
in
range
(
len
(
universe
)):
zones
.
append
([])
for
y
in
range
(
len
(
universe
[
0
])):
zones
[
x
].
append
((
x
*
width
/
100
,(
x
+
1
)
*
width
/
100
,
y
*
width
/
100
,(
y
+
1
)
*
width
/
100
))
for
x
in
range
(
len
(
universe
)):
for
y
in
range
(
len
(
universe
[
0
])):
if
universe
[
x
][
y
]
==
1
:
canvas
.
create_rectangle
(
zones
[
x
][
y
],
fill
=
"
black
"
)
zones
.
append
(
canvas
.
create_rectangle
(
x
*
width
/
100
,(
x
+
1
)
*
width
/
100
,
y
*
width
/
100
,(
y
+
1
)
*
width
/
100
),
fill
=
"
black
"
)
else
:
zones
.
append
(
canvas
.
create_rectangle
(
x
*
width
/
100
,(
x
+
1
)
*
width
/
100
,
y
*
width
/
100
,(
y
+
1
)
*
width
/
100
,
fill
=
"
white
"
))
def
update_grid
():
"""
mets la grille a jours
"""
for
x
in
range
(
len
(
universe
)):
for
y
in
range
(
len
(
universe
[
0
])):
if
universe
[
x
][
y
]
==
0
:
if
naissance
([
x
][
y
])
==
1
:
"
colorier la case zones[x][y] en vert
"
else
:
canvas
.
create_rectangle
(
zones
[
x
][
y
],
fill
=
"
white
"
)
if
survival
(
universe
[
x
][
y
])
==
0
:
"
colorier la case zones[x][y] en rouge
"
universe
=
generation
(
universe
)
def
create_cell_on_click
(
event
):
"""
créer une cellule vivante la ou l
'
utilisateur clique
"""
x
=
event
.
x
//
(
width
/
100
)
y
=
event
.
y
//
(
heigth
/
100
)
universe
[
x
][
y
]
=
1
create_a_grid
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment