added base file and a hello world with pyglet
This commit is contained in:
parent
47204a997e
commit
445ade8c33
4 changed files with 50 additions and 0 deletions
9
.gitignore
vendored
9
.gitignore
vendored
|
@ -127,3 +127,12 @@ dmypy.json
|
||||||
|
|
||||||
# Pyre type checker
|
# Pyre type checker
|
||||||
.pyre/
|
.pyre/
|
||||||
|
/.idea/.gitignore
|
||||||
|
/.idea/discord.xml
|
||||||
|
/.idea/markdown.xml
|
||||||
|
/.idea/misc.xml
|
||||||
|
/.idea/modules.xml
|
||||||
|
/.idea/inspectionProfiles/profiles_settings.xml
|
||||||
|
/.idea/inspectionProfiles/Project_Default.xml
|
||||||
|
/.idea/Projet_S6.iml
|
||||||
|
/.idea/vcs.xml
|
||||||
|
|
1
README.md
Normal file
1
README.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
# Projet S6
|
39
main.pyw
Normal file
39
main.pyw
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
import pyglet
|
||||||
|
|
||||||
|
|
||||||
|
# Créer une fenêtre
|
||||||
|
window = pyglet.window.Window(resizable=True)
|
||||||
|
|
||||||
|
# Créer un texte "Hello World !"
|
||||||
|
label = pyglet.text.Label(
|
||||||
|
"Hello World !",
|
||||||
|
anchor_x="center",
|
||||||
|
anchor_y="center"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# Lorsque la fenêtre change de taille, change la position du texte pour le centrer
|
||||||
|
@window.event
|
||||||
|
def on_resize(width: int, height: int):
|
||||||
|
label.x = width // 2
|
||||||
|
label.y = height // 2
|
||||||
|
|
||||||
|
|
||||||
|
# Lorsqu'une touche est enfoncée
|
||||||
|
@window.event
|
||||||
|
def on_key_press(symbol, modifiers):
|
||||||
|
print(
|
||||||
|
pyglet.window.key.symbol_string(symbol),
|
||||||
|
pyglet.window.key.modifiers_string(modifiers)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# À chaque frame, rafraichi la fenêtre et dessine le texte
|
||||||
|
@window.event
|
||||||
|
def on_draw():
|
||||||
|
window.clear()
|
||||||
|
label.draw()
|
||||||
|
|
||||||
|
|
||||||
|
# Lance la fenêtre
|
||||||
|
pyglet.app.run()
|
1
requirements.txt
Normal file
1
requirements.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
pyglet
|
Loading…
Reference in a new issue