Accueil > > > LES CONTES DE MONTE CRYPTO
LES CONTES DE MONTE CRYPTO
Information sur la source
Description
Inspiré du jeu d'infogramme pour Thomson TO8, mon code propose différents textes cryptés qu'il faut décoder à l'aide d'indices.
Pour éviter de surcharger l'archive zip, je n'ai inclus qu'un seul texte, mais il est possible d'en ajouter une infinitée via l'utilitaire joint(fichier ajouter.py)
Pour les plus nostalgiques d'entre vous, quelques bons sites:
http://nostalgies.thomsonistes.org/
http: //dcmoto.free.fr/
http://dcmoto.free.fr/prog/000/ index.html
Source
- # -*- coding: cp1252 -*-
- # Les contes de Monte Crypto est un jeu pour Thomson TO8 et suppérieurs.
- # Je m'en suis inspirer pour écrire ce petit jeu ludique et estival ;)
- # Amaury
- from Tkinter import *
- import os
- import time
- import tkFont
- import random
- import tkMessageBox
- import winsound
-
- os.chdir("source")
-
- lettres=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
- LETTRES=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
-
- points=0
-
-
- def GUI():
-
- global texte,root,bou1,bou2,bou3,bou4,img,LETTRES,entrees,affichage,ind
-
- root=Tk()
-
- root.title("Les Contes de Monte Crypto")
-
- police=tkFont.Font(family="times", size=20, weight=NORMAL)
- police2=tkFont.Font(family="times", size=20, weight=NORMAL)
- police3=tkFont.Font(family="symbol", size=20, weight=NORMAL)
- police4=tkFont.Font(family="symbol", size=20, weight=NORMAL)
- police5=tkFont.Font(family="times", size=10, weight=NORMAL)
-
- img=PhotoImage(file="start.gif")
- can=Label(root,image=img)
- bou1=Button(root,text="Dévoiler indice 1",font=police5)
- bou2=Button(root,text="Dévoiler indice 2",font=police5)
- bou3=Button(root,text="Dévoiler indice 3",font=police5)
- bou4=Button(root,text="Dévoiler indice 4",font=police5)
- lst=Listbox(root,width=30,height=47,bg="aquamarine",fg="blue")
- affichage=Label(root,text="Votre score : 0",font=police2)
-
- texte=Text(root,width=46,height=24,font=police,fg="blue",bg="black",state="normal")
- ind=Text(root,width=30,height=6,font=police4,fg="blue",bg="black",state="normal")
- texte.tag_config("min",foreground="green",font=police)
- texte.tag_config("maj",foreground="red",font=police3)
- ind.tag_config("min",foreground="green",font=police2)
- ind.tag_config("maj",foreground="red",font=police4)
-
- bou1.configure(command=lambda ar1=0, ar2=bou1 : Devoiler (ar1,ar2))
- bou2.configure(command=lambda ar1=2, ar2=bou2 : Devoiler (ar1,ar2))
- bou3.configure(command=lambda ar1=4, ar2=bou3 : Devoiler (ar1,ar2))
- bou4.configure(command=lambda ar1=6, ar2=bou4 : Devoiler (ar1,ar2))
- lst.bind("<Double-1>",lambda ar1 , ar2=lst : Load(ar1,ar2))
-
- a=30
- b=1
- c=0
- entrees={}
-
- for i in LETTRES:
- Label(root,text=i+":", font=police4,fg="red").grid(row=a,column=b)
- entrees[i]=Entry(root,width=2)
- entrees[i].grid(row=a,column=b+1)
- entrees[i].bind("<Return>",lambda ar1 , ar2=i : Decoder(ar1,ar2))
- if (c==12):
- a=31
- b=1
- else:
- b+=2
-
- c+=1
-
- fichier=open("liste",'r')
- temp=fichier.read()
- fichier.close()
-
- temp=temp.split('\n')
-
- for i in temp:
- lst.insert(END,i)
-
- can .grid(row=1,column=0)
- bou1.grid(row=2,column=0)
- bou2.grid(row=3,column=0)
- bou3.grid(row=4,column=0)
- bou4.grid(row=5,column=0)
- texte.grid(row=1,column=1,rowspan=29,columnspan=26)
- lst.grid(row=0,column=30,rowspan=30)
- affichage.grid(row=6,column=0)
- ind.grid(row=7,column=0)
-
- root.mainloop()
-
- def Devoiler(indice,bouton):
-
- global indices,etat,points,ind,LETTRES,lettres
-
- ind.configure(state="normal")
-
-
- temp=indices[indice] + " : " + indices[indice+1]
- temp=temp.replace('\n','')
- etat[indice/2]=1
-
- points-=10
-
- bouton.configure(state="disable")
- for i in temp:
- if i in LETTRES:
- ind.insert(END,i,"maj")
-
- else:
- ind.insert(END,i,"min")
- ind.insert(END,'\n')
-
- ind.configure(state="disable")
-
- Update()
-
- def Load(e,liste):
-
- global indices,contenu,img,titre,bou1,bou2,bou3,bou4,texte,flag,entrees,LETTRES,etat,attendu,courant,ind
-
- texte.configure(state="normal")
-
- etat=[0,0,0,0]
- ind.configure(state="normal")
- ind.delete(0.0,END)
- ind.configure(state="disable")
-
- attendu,courant=0,0
-
- indices=[]
-
- flag=True
-
- path=liste.get(liste.curselection())
-
- fichier=open(path,'r')
-
- titre=path
- titre=titre.replace('\n','')
-
- root.title("Les Contes de Monte Crypto: " + titre)
-
-
- img.configure(file=str(path+'.gif'))
-
- a=0
-
- while (a<8):
- indices.append(fichier.readline())
- a+=1
-
- a=1
-
- while(a<9):
-
- indices[a]=Encoder(indices[a])
- a+=2
-
- contenu=fichier.read()
-
- texte.delete(0.0,END)
- temp=Encoder(contenu)
- for i in temp:
- if i in LETTRES:
- texte.insert(END,i,"maj")
- else:
- texte.insert(END,i,"min")
-
- bou1.configure(text="Dévoiler indice 1",state="normal")
- bou2.configure(text="Dévoiler indice 2",state="normal")
- bou3.configure(text="Dévoiler indice 3",state="normal")
- bou4.configure(text="Dévoiler indice 4",state="normal")
-
- temp=texte.get(0.0,END)
-
- for i in LETTRES:
- if i in temp:
- entrees[i].configure(state="normal",bg="blue")
- attendu+=1
- else:
- entrees[i].configure(state="disable")
-
- fichier.close()
- texte.configure(state="disable")
-
- def Encoder(texte):
-
- global lettres,flag,tableau
-
- if flag:
- tableau=CreerTableCodage()
- flag=False
-
- a=0
- for i in lettres:
- texte=texte.replace(i,tableau[a])
- a+=1
-
- return texte
-
- def Update():
-
- global points,affichage,indices,etat,root,attendu,courant
-
-
- root.update()
-
- if courant==attendu:
-
- tkMessageBox.showinfo(title="Félicitation",message="""Félicitation!
- Vous avez terminé le niveau.""")
- winsound.PlaySound('SystemExclamation',winsound.SND_ASYNC)
-
- points+=20
-
- courant+=1
-
- affichage.configure(text="Votre score : " + str(points))
-
-
- def Decoder(e,lettre):
-
- global entrees,texte,root,decode,indices,points,courant,ind,lettres,LETTRES
-
- temp=texte.get(0.0,END)
- texte.configure(state="normal")
- try:
- new=entrees[lettre].get()
- if (decode[new]==lettre):
-
- temp=temp.replace(lettre,new)
- entrees[lettre].configure(state="disable")
-
-
- courant+=1
-
- a=1
-
- while(a<9):
-
- indices[a]=indices[a].replace(lettre,new)
- a+=2
-
- texte.delete(0.0,END)
- for i in temp:
- if i in lettres:
- texte.insert(END,i,"min")
- elif i in LETTRES:
- texte.insert(END,i,"maj")
- else:
- texte.insert(END,i)
-
- points+=5
-
- winsound.PlaySound('SystemAsterisk',winsound.SND_ASYNC )
-
- else:
- points-=5
- winsound.PlaySound('SystemHand',winsound.SND_ASYNC)
- Update()
- entrees[lettre].configure(bg="orange")
- entrees[lettre].delete(0,END)
- except KeyError:
- pass
-
- temp=ind.get(0.0,END)
- ind.configure(state="normal")
- try:
- new=entrees[lettre].get()
- if (decode[new]==lettre):
-
- temp=temp.replace(lettre,new)
- entrees[lettre].configure(state="disable")
-
-
- a=1
-
- while(a<9):
-
- indices[a]=indices[a].replace(lettre,new)
- a+=2
-
- ind.delete(0.0,END)
- for i in temp:
- if i in lettres:
- ind.insert(END,i,"min")
- elif i in LETTRES:
- ind.insert(END,i,"maj")
- else:
- ind.insert(END,i)
-
- except KeyError:
- pass
-
-
- Update()
- texte.configure(state="disable")
- ind.configure(state="disable")
-
- def CreerTableCodage():
-
- global decode,lettres
-
- decode={}
-
- dispo=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
- table=[]
-
- a=0
-
- while (a<26):
- ind=random.randint(0,len(dispo)-1)
- table.append(dispo[ind])
- decode[lettres[a]]=dispo[ind]
- del (dispo[ind])
- a+=1
-
- return table
-
-
- GUI()
-
# -*- coding: cp1252 -*-
# Les contes de Monte Crypto est un jeu pour Thomson TO8 et suppérieurs.
# Je m'en suis inspirer pour écrire ce petit jeu ludique et estival ;)
# Amaury
from Tkinter import *
import os
import time
import tkFont
import random
import tkMessageBox
import winsound
os.chdir("source")
lettres=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
LETTRES=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
points=0
def GUI():
global texte,root,bou1,bou2,bou3,bou4,img,LETTRES,entrees,affichage,ind
root=Tk()
root.title("Les Contes de Monte Crypto")
police=tkFont.Font(family="times", size=20, weight=NORMAL)
police2=tkFont.Font(family="times", size=20, weight=NORMAL)
police3=tkFont.Font(family="symbol", size=20, weight=NORMAL)
police4=tkFont.Font(family="symbol", size=20, weight=NORMAL)
police5=tkFont.Font(family="times", size=10, weight=NORMAL)
img=PhotoImage(file="start.gif")
can=Label(root,image=img)
bou1=Button(root,text="Dévoiler indice 1",font=police5)
bou2=Button(root,text="Dévoiler indice 2",font=police5)
bou3=Button(root,text="Dévoiler indice 3",font=police5)
bou4=Button(root,text="Dévoiler indice 4",font=police5)
lst=Listbox(root,width=30,height=47,bg="aquamarine",fg="blue")
affichage=Label(root,text="Votre score : 0",font=police2)
texte=Text(root,width=46,height=24,font=police,fg="blue",bg="black",state="normal")
ind=Text(root,width=30,height=6,font=police4,fg="blue",bg="black",state="normal")
texte.tag_config("min",foreground="green",font=police)
texte.tag_config("maj",foreground="red",font=police3)
ind.tag_config("min",foreground="green",font=police2)
ind.tag_config("maj",foreground="red",font=police4)
bou1.configure(command=lambda ar1=0, ar2=bou1 : Devoiler (ar1,ar2))
bou2.configure(command=lambda ar1=2, ar2=bou2 : Devoiler (ar1,ar2))
bou3.configure(command=lambda ar1=4, ar2=bou3 : Devoiler (ar1,ar2))
bou4.configure(command=lambda ar1=6, ar2=bou4 : Devoiler (ar1,ar2))
lst.bind("<Double-1>",lambda ar1 , ar2=lst : Load(ar1,ar2))
a=30
b=1
c=0
entrees={}
for i in LETTRES:
Label(root,text=i+":", font=police4,fg="red").grid(row=a,column=b)
entrees[i]=Entry(root,width=2)
entrees[i].grid(row=a,column=b+1)
entrees[i].bind("<Return>",lambda ar1 , ar2=i : Decoder(ar1,ar2))
if (c==12):
a=31
b=1
else:
b+=2
c+=1
fichier=open("liste",'r')
temp=fichier.read()
fichier.close()
temp=temp.split('\n')
for i in temp:
lst.insert(END,i)
can .grid(row=1,column=0)
bou1.grid(row=2,column=0)
bou2.grid(row=3,column=0)
bou3.grid(row=4,column=0)
bou4.grid(row=5,column=0)
texte.grid(row=1,column=1,rowspan=29,columnspan=26)
lst.grid(row=0,column=30,rowspan=30)
affichage.grid(row=6,column=0)
ind.grid(row=7,column=0)
root.mainloop()
def Devoiler(indice,bouton):
global indices,etat,points,ind,LETTRES,lettres
ind.configure(state="normal")
temp=indices[indice] + " : " + indices[indice+1]
temp=temp.replace('\n','')
etat[indice/2]=1
points-=10
bouton.configure(state="disable")
for i in temp:
if i in LETTRES:
ind.insert(END,i,"maj")
else:
ind.insert(END,i,"min")
ind.insert(END,'\n')
ind.configure(state="disable")
Update()
def Load(e,liste):
global indices,contenu,img,titre,bou1,bou2,bou3,bou4,texte,flag,entrees,LETTRES,etat,attendu,courant,ind
texte.configure(state="normal")
etat=[0,0,0,0]
ind.configure(state="normal")
ind.delete(0.0,END)
ind.configure(state="disable")
attendu,courant=0,0
indices=[]
flag=True
path=liste.get(liste.curselection())
fichier=open(path,'r')
titre=path
titre=titre.replace('\n','')
root.title("Les Contes de Monte Crypto: " + titre)
img.configure(file=str(path+'.gif'))
a=0
while (a<8):
indices.append(fichier.readline())
a+=1
a=1
while(a<9):
indices[a]=Encoder(indices[a])
a+=2
contenu=fichier.read()
texte.delete(0.0,END)
temp=Encoder(contenu)
for i in temp:
if i in LETTRES:
texte.insert(END,i,"maj")
else:
texte.insert(END,i,"min")
bou1.configure(text="Dévoiler indice 1",state="normal")
bou2.configure(text="Dévoiler indice 2",state="normal")
bou3.configure(text="Dévoiler indice 3",state="normal")
bou4.configure(text="Dévoiler indice 4",state="normal")
temp=texte.get(0.0,END)
for i in LETTRES:
if i in temp:
entrees[i].configure(state="normal",bg="blue")
attendu+=1
else:
entrees[i].configure(state="disable")
fichier.close()
texte.configure(state="disable")
def Encoder(texte):
global lettres,flag,tableau
if flag:
tableau=CreerTableCodage()
flag=False
a=0
for i in lettres:
texte=texte.replace(i,tableau[a])
a+=1
return texte
def Update():
global points,affichage,indices,etat,root,attendu,courant
root.update()
if courant==attendu:
tkMessageBox.showinfo(title="Félicitation",message="""Félicitation!
Vous avez terminé le niveau.""")
winsound.PlaySound('SystemExclamation',winsound.SND_ASYNC)
points+=20
courant+=1
affichage.configure(text="Votre score : " + str(points))
def Decoder(e,lettre):
global entrees,texte,root,decode,indices,points,courant,ind,lettres,LETTRES
temp=texte.get(0.0,END)
texte.configure(state="normal")
try:
new=entrees[lettre].get()
if (decode[new]==lettre):
temp=temp.replace(lettre,new)
entrees[lettre].configure(state="disable")
courant+=1
a=1
while(a<9):
indices[a]=indices[a].replace(lettre,new)
a+=2
texte.delete(0.0,END)
for i in temp:
if i in lettres:
texte.insert(END,i,"min")
elif i in LETTRES:
texte.insert(END,i,"maj")
else:
texte.insert(END,i)
points+=5
winsound.PlaySound('SystemAsterisk',winsound.SND_ASYNC )
else:
points-=5
winsound.PlaySound('SystemHand',winsound.SND_ASYNC)
Update()
entrees[lettre].configure(bg="orange")
entrees[lettre].delete(0,END)
except KeyError:
pass
temp=ind.get(0.0,END)
ind.configure(state="normal")
try:
new=entrees[lettre].get()
if (decode[new]==lettre):
temp=temp.replace(lettre,new)
entrees[lettre].configure(state="disable")
a=1
while(a<9):
indices[a]=indices[a].replace(lettre,new)
a+=2
ind.delete(0.0,END)
for i in temp:
if i in lettres:
ind.insert(END,i,"min")
elif i in LETTRES:
ind.insert(END,i,"maj")
else:
ind.insert(END,i)
except KeyError:
pass
Update()
texte.configure(state="disable")
ind.configure(state="disable")
def CreerTableCodage():
global decode,lettres
decode={}
dispo=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
table=[]
a=0
while (a<26):
ind=random.randint(0,len(dispo)-1)
table.append(dispo[ind])
decode[lettres[a]]=dispo[ind]
del (dispo[ind])
a+=1
return table
GUI()
Conclusion
Ce code m'a permis de me replonger dans la programmation d'interfaces graphiques, avec notamment la découverte du widget Text.
Historique
- 12 juillet 2009 18:30:19 :
- ajout de liens web
- 12 juillet 2009 18:58:50 :
- Mauvaise gestion des états "normal" et "disable" des widgets Text
- 12 juillet 2009 22:20:54 :
- je n'ai pas résisté à l'envie d'ajouter les bruits et les textes originaux...
Sources du même auteur
Sources de la même categorie
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
Tkinter + Text + coloration [ par Kickaha59 ]
Bonjour à tous,Je souhaite colorer certains mots afficher dans une fenêtre avec la fonction Text de Tkinter.Par exemple je veux colorer en vert tout l
PYTHON TKINTER utilisation de labels [ par bichon3001 ]
Bonjour, Je souhaite utiliser l'interface graphique TKinter de Python pour appeler une fonction avec un bouton, et afficher le résultat dans un label.
Réalisation d'un plus ou moins sur Tkinter [ par kuritsu ]
Bonsoir tout le monde, et je vous souhaite la bonne année à tous par la même occasion. Je viens de me mettre à la programmation sous Python, et j'avo
Positionner le curseur dans un widget text (Tkinter) [ par Souslannodenime ]
Voila, j'ai crée un client pour un système de chat via socket(un genre de irc-like) et j'aimer savoir comment faire pour que le widget text(qui me se
Python 2.6 avec Tkinter 8.6 [ par zarash ]
Bonjour, Voici mon probleme : Je souhaite utiliser une option du widget text de Tkinter qui n'existe que dans la version 8.6.Il s'agit de la rotation
[php][sql]recherche multiple dans une base de donnée sql [ par jeff83fr ]
Bonjour, j'ai un problème de récupération a ma base de donné, je m explique je souhaiterai faire un annuaire je souhaiterai donc faire une page un p
Tkinter [ par williammalavelle ]
Bonjour à tous, Question stupide : je débute sous Python et sous Tkinter. J'ai un script python que je souhaite lié à Tkinter (j'ai préparé les fenêt
Selecteur de couleur [ par PunkFloyd91 ]
Bonjour, je suis débutant et essais de créer un petit logiciel de traitement d'images du style "paint" en python 3 avec la 'library' de tkinter. Je ch
Calculateur de pH/Problème radio boutton [ par adriber ]
Bonjour je me suis lancé dans un projet de calculateur de ph (chimie). Je suis face à un dernier problème (et non des moindres). Voici mon code: [code
a propos de tkinter [ par isaaclamour ]
bonjour les amis debutant en python je suis entrain de concevoir une application de telephonie sur ip jai donc realisé une interface graphique (avec d
|
Derniers Blogs
IMAGINE CUP 2012, MAKE A SIGN EN FINALEIMAGINE CUP 2012, MAKE A SIGN EN FINALE par junarnoalg
Voilà qui est fait, la nouvelle est officielle ! L'équipe belge "Make a Sign" va au pays des kangourous défendre son projet dans la catégorie Software Design. http://www.imaginecup.com/CompetitionsContent/Competition/WorldwideFinalists.aspx V...
Cliquez pour lire la suite de l'article par junarnoalg KINECT 1.5 IS OUT !KINECT 1.5 IS OUT ! par Vko
La version 1.5 du Kinect For Microsoft vient tout juste de sortir ! Plein de nouveautés: Tracking de squelette en Near Mode Détection en position assise Détection faciale avec un SDK dédié Documentation et des guideline (enfin) Un out...
Cliquez pour lire la suite de l'article par Vko LES ACTUALITéS DE LA SEMAINE SUR C2I.FR (14 MAI - 20 MAI) LES ACTUALITéS DE LA SEMAINE SUR C2I.FR (14 MAI - 20 MAI) par richardc
Mise à jour des Web API du 14 Mai
Réservez dès maintenant votre journée du 20 juin pour le Windows Azure Dev Camp 2012 à Paris
Mise à jour de Team Foundation Service
MechCommander 2 sur Windows 8
Entity Framework 5 Release Candidate e...
Cliquez pour lire la suite de l'article par richardc REACTIVE EXTENSIONS : CONSOMMER DES SERVICES AVEC RX PARTIE 3, LES PIèGES à éVITERREACTIVE EXTENSIONS : CONSOMMER DES SERVICES AVEC RX PARTIE 3, LES PIèGES à éVITER par Groc
Une mauvaise utilisation de rx lors de l'écriture d'une couche d'accès à des services peut conduire à des cas embarassants avec des erreurs mal gérées, des appels qui ne partent lorsqu'ils le devraient, et même des résultats incorrects . le tout nuis...
Cliquez pour lire la suite de l'article par Groc SHAREPOINT BLOG SITE, PROBLèME D'ARCHIVESSHAREPOINT BLOG SITE, PROBLèME D'ARCHIVES par junarnoalg
Dernièrement, nous avons migré le site
myTIC
vers un nouveau serveur SharePoint 2010. Dans les contenus que nous vouloins récupérer, nous avions un certain nombre de blogs.
Nous avons utilisé les commandes Power...
Cliquez pour lire la suite de l'article par junarnoalg
Logiciels
974 Application Server (12.2.4.0)974 APPLICATION SERVER (12.2.4.0)Développez de puissantes applications dans un environnement de 'cloud computing', clusterisé, séc... Cliquez pour télécharger 974 Application Server vPicture (1.4.2.1)VPICTURE (1.4.2.1)Avec vPicture, hébergez vos images facilement et rapidement.
vPicture est un utilitaire simple, ... Cliquez pour télécharger vPicture Easy-Planning (2.2.1.6)EASY-PLANNING (2.2.1.6)Easy-Planning permet de créer des plannings sous la représentation de diagrammes et est adapté au... Cliquez pour télécharger Easy-Planning COM-BACKUP (2.0)COM-BACKUP (2.0)
COM-BACKUP est un logiciel de sauvegarde qui permet de planifier les sauvegardes de vos dossiers ...
Cliquez pour télécharger COM-BACKUP mySongBook Player (1.0.0)MYSONGBOOK PLAYER (1.0.0)mySongBook Player est un logiciel gratuit permettant l'accès à une archive de tablatures/partitio... Cliquez pour télécharger mySongBook Player
|