begin process at 2012 05 23 23:34:22
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Graphique

 > AFFICHEUR 7 SEGMENTS

AFFICHEUR 7 SEGMENTS


 Information sur la source

Note :
9 / 10 - par 2 personnes
9,00 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10
Catégorie :Graphique Classé sous :afficheur, sept segments, 7 segments Niveau :Débutant Date de création :22/10/2007 Vu :4 388

Auteur : kouakou021988

Ecrire un message privé
Commentaire sur cette source (3)
Ajouter un commentaire et/ou une note

 Description

Ben c'est juste un afficheur 7 segemnts(affiche les nombres de 0 à 9)relié a votre propre clavier numérique.

Source

  • # -*- coding: iso8859-15 -*-
  • from Tkinter import*
  • dic={1: (70, 45, 130, 35), 2: (130, 45, 140, 95), 3: (130, 105, 140, 165), 4: (130, 165, 70, 175),
  • 5: (60, 165, 70, 105), 6: (70, 95, 60, 45), 7: (70, 95, 130, 105)}
  • code={1:(2,3),2:(1,2,7,5,4),3:(1,2,7,3,4),4:(6,7,2,3),5:(1,6,7,3,4),6:(1,6,5,4,3,7),7:(1,2,3),8:(1,2,3,4,5,6,7)
  • ,9:(6,1,2,3,4,7),0:(1,2,3,4,5,6)}
  • class Afficheur(Frame):
  • def __init__(self):
  • Frame.__init__(self)
  • self.master.title("::.Afficheur Sept Segments.::")
  • self.configure(bg="grey40",bd=0,relief=FLAT)
  • self.master.resizable(width=False, height=False)
  • self.master.protocol("WM_DELETE_WINDOW", self.quitter)
  • self.pack(padx =8, pady =8)
  • self.lst=[]
  • self.build()
  • def build(self):
  • self.can=Canvas(self,bg='black',relief=FLAT,width =200,height =200)
  • self.can.grid(row=0,column=0)
  • liste=[]
  • for i in [1,2,3,4,5,6,7]: #Mise en place des segments de l'afficheur
  • v=dic[i]
  • liste.append(v)
  • for (w,x,y,z) in liste:
  • p=self.can.create_rectangle(w,x,y,z,fill='black')
  • self.lst.append(p)
  • liste=[]
  • fram=Frame(self,bd=0,relief=FLAT,bg='white')
  • fram.grid(row=0,column=1)
  • Button(fram,text='1',font='arial 10 bold',bg='white',relief=FLAT,
  • command= lambda arg=1: self.affiche(arg)).grid(row=1,column=1,padx=2,pady=2) #Mise en place des boutons du clavier numerique
  • Button(fram,text='2',font='arial 10 bold',bg='white',relief=FLAT,
  • command= lambda arg=2: self.affiche(arg)).grid(row=1,column=2,padx=2,pady=2)
  • Button(fram,text='3',font='arial 10 bold',bg='white',relief=FLAT,
  • command= lambda arg=3: self.affiche(arg)).grid(row=1,column=3,padx=2,pady=2)
  • Button(fram,text='4',font='arial 10 bold',bg='white',relief=FLAT,
  • command= lambda arg=4: self.affiche(arg)).grid(row=2,column=1,padx=2,pady=2)
  • Button(fram,text='5',font='arial 10 bold',bg='white',relief=FLAT,
  • command= lambda arg=5: self.affiche(arg)).grid(row=2,column=2,padx=2,pady=2)
  • Button(fram,text='6',font='arial 10 bold',bg='white',relief=FLAT,
  • command= lambda arg=6: self.affiche(arg)).grid(row=2,column=3,padx=2,pady=2)
  • Button(fram,text='7',font='arial 10 bold',bg='white',relief=FLAT,
  • command= lambda arg=7: self.affiche(arg)).grid(row=3,column=1,padx=2,pady=2)
  • Button(fram,text='8',font='arial 10 bold',bg='white',relief=FLAT,
  • command= lambda arg=8: self.affiche(arg)).grid(row=3,column=2,padx=2,pady=2)
  • Button(fram,text='9',font='arial 10 bold',bg='white',relief=FLAT,
  • command= lambda arg=9: self.affiche(arg)).grid(row=3,column=3,padx=2,pady=2)
  • Button(fram,text='0',font='arial 10 bold',bg='white',relief=FLAT,
  • command= lambda arg=0: self.affiche(arg)).grid(row=4,column=1,columnspan=3,padx=2,pady=2)
  • Button(self,text='Quitter',font='arial 10 bold',bg='grey40',relief=FLAT,command=self.quitter).grid(pady=2)
  • self.can.bind_all('<Key>',self.touche)
  • self.master.bind('<Escape>',self.quitter) #Pour sortir avec la touche Echap
  • def quitter(self,event=None):
  • self.can.delete(ALL)
  • self.master.destroy()
  • def affiche(self,arg=None):
  • self.initialisation()
  • v=list(code[arg])
  • for i in v:
  • self.can.itemconfig(i,fill='red')
  • def initialisation(self):
  • for i in self.lst:
  • self.can.itemconfig(i,fill='black')
  • def touche(self,event=None):
  • try: a=int(event.char)
  • except: pass
  • else:
  • self.initialisation()
  • v=list(code[a])
  • for i in v:
  • self.can.itemconfig(i,fill='red')
  • if __name__=='__main__':
  • app=Afficheur()
  • app.mainloop()
# -*- coding: iso8859-15 -*-

from Tkinter import*

dic={1: (70, 45, 130, 35), 2: (130, 45, 140, 95), 3: (130, 105, 140, 165), 4: (130, 165, 70, 175),
 5: (60, 165, 70, 105), 6: (70, 95, 60, 45), 7: (70, 95, 130, 105)}
code={1:(2,3),2:(1,2,7,5,4),3:(1,2,7,3,4),4:(6,7,2,3),5:(1,6,7,3,4),6:(1,6,5,4,3,7),7:(1,2,3),8:(1,2,3,4,5,6,7)
      ,9:(6,1,2,3,4,7),0:(1,2,3,4,5,6)}
class Afficheur(Frame):

        def __init__(self):
                Frame.__init__(self)
                self.master.title("::.Afficheur Sept Segments.::")
                self.configure(bg="grey40",bd=0,relief=FLAT)
                self.master.resizable(width=False, height=False)
                self.master.protocol("WM_DELETE_WINDOW", self.quitter)
                self.pack(padx =8, pady =8)
                self.lst=[]
                self.build()

        def build(self):
                self.can=Canvas(self,bg='black',relief=FLAT,width =200,height =200)
                self.can.grid(row=0,column=0)
                liste=[]
                for i in [1,2,3,4,5,6,7]:                                   #Mise en place des segments de l'afficheur
                        v=dic[i]
                        liste.append(v)
                        for (w,x,y,z) in liste:
                                p=self.can.create_rectangle(w,x,y,z,fill='black')
                                self.lst.append(p)
                                liste=[]
                fram=Frame(self,bd=0,relief=FLAT,bg='white')
                fram.grid(row=0,column=1)
                Button(fram,text='1',font='arial 10 bold',bg='white',relief=FLAT,
                       command= lambda arg=1: self.affiche(arg)).grid(row=1,column=1,padx=2,pady=2)     #Mise en place des boutons du clavier numerique
                Button(fram,text='2',font='arial 10 bold',bg='white',relief=FLAT,
                       command= lambda arg=2: self.affiche(arg)).grid(row=1,column=2,padx=2,pady=2)
                Button(fram,text='3',font='arial 10 bold',bg='white',relief=FLAT,
                       command= lambda arg=3: self.affiche(arg)).grid(row=1,column=3,padx=2,pady=2)
                Button(fram,text='4',font='arial 10 bold',bg='white',relief=FLAT,
                       command= lambda arg=4: self.affiche(arg)).grid(row=2,column=1,padx=2,pady=2)
                Button(fram,text='5',font='arial 10 bold',bg='white',relief=FLAT,
                       command= lambda arg=5: self.affiche(arg)).grid(row=2,column=2,padx=2,pady=2)
                Button(fram,text='6',font='arial 10 bold',bg='white',relief=FLAT,
                       command= lambda arg=6: self.affiche(arg)).grid(row=2,column=3,padx=2,pady=2)
                Button(fram,text='7',font='arial 10 bold',bg='white',relief=FLAT,
                       command= lambda arg=7: self.affiche(arg)).grid(row=3,column=1,padx=2,pady=2)
                Button(fram,text='8',font='arial 10 bold',bg='white',relief=FLAT,
                       command= lambda arg=8: self.affiche(arg)).grid(row=3,column=2,padx=2,pady=2)
                Button(fram,text='9',font='arial 10 bold',bg='white',relief=FLAT,
                       command= lambda arg=9: self.affiche(arg)).grid(row=3,column=3,padx=2,pady=2)
                Button(fram,text='0',font='arial 10 bold',bg='white',relief=FLAT,
                       command= lambda arg=0: self.affiche(arg)).grid(row=4,column=1,columnspan=3,padx=2,pady=2)
                Button(self,text='Quitter',font='arial 10 bold',bg='grey40',relief=FLAT,command=self.quitter).grid(pady=2)
                self.can.bind_all('<Key>',self.touche)
                self.master.bind('<Escape>',self.quitter)                                   #Pour sortir avec la touche Echap

        def quitter(self,event=None):
                self.can.delete(ALL)
                self.master.destroy()

	def affiche(self,arg=None):
                self.initialisation()
                v=list(code[arg])
                for i in v:
                        self.can.itemconfig(i,fill='red')
                

        def initialisation(self):
                for i in self.lst:
                        self.can.itemconfig(i,fill='black')
                        
        def touche(self,event=None):
                try:    a=int(event.char)
                except: pass
                else:
                        self.initialisation()
                        v=list(code[a])
                        for i in v:
                                self.can.itemconfig(i,fill='red')

if __name__=='__main__':
        app=Afficheur()
        app.mainloop()

 Conclusion

C'est mon premier code.Merci


 Sources du même auteur

Source avec Zip MON REPERTOIRE
WX_REVEIL
REVEIL 2 EN PYTHON
TRACER UNE FONCTION
JEU DE MOT

 Sources de la même categorie

Source avec Zip Source avec une capture JEU DE LA VIE SIMPLE ET GRAPHIQUE (TKINTER) EN PYTHON 3 par sodawil
Source avec Zip Source avec une capture PROGRAMMATION par grephit
Source avec Zip Source avec une capture EDITEUR DESSIN par grephit
Source avec Zip Source avec une capture PORTRAIT ROBOT par grephit
Source avec Zip ROTRING SCRIPT DESSIN par grephit

 Sources en rapport avec celle ci

Source avec Zip Source avec une capture PROGRESS BAR POUR TKINTER par amaury74
Source avec Zip Source avec une capture DOUBLE AFFICHEUR 7 SEGMENTS par amaury74
Source avec Zip Source avec une capture GALVANOMÈTRE par amaury74

Commentaires et avis

Commentaire de mouss11 le 29/10/2007 20:13:24 10/10

Original comme code, marche impeccable.
Qui sait, ça pourrait me servir pour un affichage.
Bonne continuation

Commentaire de aera group le 31/10/2007 14:26:59 8/10

Ouai, c'est pas mal pour un premier code !!! 8/10

Commentaire de orguesauxerre le 07/04/2011 14:22:15

Je cherche la même chose, mais en HTML...
Cordialement.
J-M d'orguesauxerre

 Ajouter un commentaire




Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Mai 2012
LMMJVSD
 123456
78910111213
14151617181920
21222324252627
28293031   

Consulter la suite du CalendriCode

A découvrir



 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 1,716 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales