Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Groupe12_Memory
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
Ouhmidou Sarra
Groupe12_Memory
Commits
01ee46f8
Commit
01ee46f8
authored
1 year ago
by
Boulaares Myriam
Browse files
Options
Downloads
Patches
Plain Diff
fenetre des choix et des themes avec des bouttons choix multiples
parent
31c916b1
Branches
special2
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
choix2.py
+30
-22
30 additions, 22 deletions
choix2.py
with
30 additions
and
22 deletions
choix2.py
+
30
−
22
View file @
01ee46f8
import
tkinter
as
tk
from
tkinter
import
ttk
def
choisir_theme
(
theme
):
print
(
f
"
Thème choisi :
{
theme
}
"
)
def
choisir_niveau
(
niveau
):
print
(
f
"
Niveau choisi :
{
niveau
}
"
)
def
choisir_niveau
(
*
args
):
print
(
f
"
Niveau choisi :
{
niveau
_var
.
get
()
}
"
)
def
enregistrer_nom_joueur
():
nom_joueur
=
nom_joueur_entry
.
get
()
...
...
@@ -13,34 +14,41 @@ def enregistrer_nom_joueur():
# Création de la fenêtre principale
fenetre
=
tk
.
Tk
()
fenetre
.
title
(
"
Jeu
"
)
fenetre
.
geometry
(
"
700x700
"
)
# Taille de la fenêtre
fenetre
.
configure
(
bg
=
'
#C597FF
'
)
# Couleur de fond
# Zone de saisie pour le nom du joueur
nom_joueur_label
=
tk
.
Label
(
fenetre
,
text
=
"
Nom du joueur:
"
)
nom_joueur_label
.
pack
(
pady
=
1
0
)
nom_joueur_entry
=
tk
.
Entry
(
fenetre
)
nom_joueur_label
=
tk
.
Label
(
fenetre
,
text
=
"
Nom du joueur:
"
,
bg
=
'
#C597FF
'
,
font
=
(
"
Arial
"
,
16
)
)
nom_joueur_label
.
pack
(
pady
=
2
0
)
nom_joueur_entry
=
tk
.
Entry
(
fenetre
,
font
=
(
"
Arial
"
,
14
)
)
nom_joueur_entry
.
pack
(
pady
=
10
)
# Boutons pour les niveaux à gauche
niveau1_button
=
tk
.
Button
(
fenetre
,
text
=
"
Niveau 1
"
,
command
=
lambda
:
choisir_niveau
(
1
),
bg
=
"
lightblue
"
,
width
=
15
,
height
=
2
)
niveau1_button
.
pack
(
side
=
tk
.
LEFT
,
padx
=
5
)
niveau2_button
=
tk
.
Button
(
fenetre
,
text
=
"
Niveau 2
"
,
command
=
lambda
:
choisir_niveau
(
2
),
bg
=
"
lightgreen
"
,
width
=
15
,
height
=
2
)
niveau2_button
.
pack
(
side
=
tk
.
LEFT
,
padx
=
5
)
niveau3_button
=
tk
.
Button
(
fenetre
,
text
=
"
Niveau 3
"
,
command
=
lambda
:
choisir_niveau
(
3
),
bg
=
"
lightcoral
"
,
width
=
15
,
height
=
2
)
niveau3_button
.
pack
(
side
=
tk
.
LEFT
,
padx
=
5
)
# Bouton pour les thèmes à droite
theme_button
=
tk
.
Menubutton
(
fenetre
,
text
=
"
Choisir Thème
"
,
bg
=
"
orange
"
,
width
=
20
,
height
=
2
)
theme_menu
=
tk
.
Menu
(
theme_button
,
tearoff
=
0
)
theme_menu
.
add_command
(
label
=
"
Thème 1
"
,
command
=
lambda
:
choisir_theme
(
1
))
theme_menu
.
add_command
(
label
=
"
Thème 2
"
,
command
=
lambda
:
choisir_theme
(
2
))
theme_menu
.
add_command
(
label
=
"
Thème 3
"
,
command
=
lambda
:
choisir_theme
(
3
))
theme_button
[
'
menu
'
]
=
theme_menu
theme_button
.
pack
(
side
=
tk
.
RIGHT
,
padx
=
5
)
# Bouton pour les niveaux
niveaux_label
=
tk
.
Label
(
fenetre
,
text
=
"
Choisir Niveau:
"
,
bg
=
'
#C597FF
'
,
font
=
(
"
Arial
"
,
16
))
niveaux_label
.
pack
(
pady
=
10
)
niveaux_values
=
[
"
Niveau 1
"
,
"
Niveau 2
"
,
"
Niveau 3
"
]
niveau_var
=
tk
.
StringVar
()
niveau_combobox
=
ttk
.
Combobox
(
fenetre
,
textvariable
=
niveau_var
,
values
=
niveaux_values
,
state
=
"
readonly
"
,
font
=
(
"
Arial
"
,
14
))
niveau_combobox
.
pack
(
pady
=
10
)
niveau_combobox
.
current
(
0
)
# Sélectionner le premier niveau par défaut
niveau_combobox
.
bind
(
"
<<ComboboxSelected>>
"
,
choisir_niveau
)
# Bouton pour les thèmes
themes_label
=
tk
.
Label
(
fenetre
,
text
=
"
Choisir Thème:
"
,
bg
=
'
#C597FF
'
,
font
=
(
"
Arial
"
,
16
))
themes_label
.
pack
(
pady
=
10
)
themes_values
=
[
"
Thème 1
"
,
"
Thème 2
"
,
"
Thème 3
"
]
theme_var
=
tk
.
StringVar
()
theme_combobox
=
ttk
.
Combobox
(
fenetre
,
textvariable
=
theme_var
,
values
=
themes_values
,
state
=
"
readonly
"
,
font
=
(
"
Arial
"
,
14
))
theme_combobox
.
pack
(
pady
=
10
)
theme_combobox
.
current
(
0
)
# Sélectionner le premier thème par défaut
theme_combobox
.
bind
(
"
<<ComboboxSelected>>
"
,
lambda
event
:
choisir_theme
(
theme_var
.
get
()))
# Bouton pour enregistrer le nom du joueur
enregistrer_button
=
tk
.
Button
(
fenetre
,
text
=
"
Enregistrer
"
,
command
=
enregistrer_nom_joueur
,
bg
=
"
orange
"
,
width
=
20
,
height
=
2
)
enregistrer_button
=
tk
.
Button
(
fenetre
,
text
=
"
Enregistrer
"
,
command
=
enregistrer_nom_joueur
,
bg
=
'
#C597FF
'
,
font
=
(
"
Arial
"
,
16
)
)
enregistrer_button
.
pack
(
pady
=
20
)
# Lancement de la boucle principale
fenetre
.
mainloop
()
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