1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| def Add(self, evt):
n = wx.TextEntryDialog(self,"Entrez le premier chiffre ici","",style = wx.OK | wx.CANCEL | wx.CENTRE)
#afficher la fenêtre tant et aussi longtemps que l'on ne la fermera pas
reponse = n.ShowModal()
#Récupération du text entré
nn = n.GetValue()
if reponse != wx.ID_OK or nn == "":
n.Destroy()
#Demande d'entrer le second numéro.
n1 = wx.TextEntryDialog(self,"Entrez le deuxième chiffre ici","",style = wx.OK | wx.CANCEL | wx.CENTRE)
reponse = n1.ShowModal()
nn = n.GetValue()
if reponse != wx.ID_OK or nn == "":
n.Destroy()
#verification si autre que des chiffres
if nn == '': #si chaine vide
winsound.PlaySound('wav_tel/Appel.wav', winsound.SND_NODEFAULT)
nn = '0' #on force a mettre 0
lnn = len(nn) #longueur de la chaine
vf = 0
for i in range(0, lnn):
if ord(nn[i]) < 48 or ord(nn[i]) > 57:
vf = 1
#recuperation du nombre en un entier numerique
if vf == 1:
winsound.PlaySound('wav_tel/Appel.wav', winsound.SND_NODEFAULT)
nb = 0
vf = 0
else:
nb = int(nn)
n.Destroy()
if reponse != wx.ID_OK or nn == "":
self.Destroy()
if reponse :
#on affiche le numéro dans la boîte de dialogue.
winsound.PlaySound('c:/Python25/wav_tel/bing.wav', winsound.SND_NODEFAULT)
d = wx.MessageDialog(self, " La réponse est :", "Affichage du résultat !", wx.OK)
d.ShowModal()
d.Destroy() |
Partager