Exemples de projets pour le bac

.

VIDEO rotation

.

html video player by EasyHtml5Video.com v4.0
<

.

CODE python rotation.py

.

.

rotation.py

from tkinter import *

from math import *

from time import *

titre = "animation"

fd = 'verdana 25 bold'

cl =[ 'red' , 'hot pink' , 'deep pink' , 'pink' , 'deep pink' , 'hot pink' ]

lg =[ 20 , 23 , 26 , 30 , 26 , 23 ]

class Balle ():

    def __init__ ( self , fenetre , can , largeur ):

        self . fenetre = fenetre

        self . can = can

        self . lar = largeur

        self . rayon = self . lar / 2 - 30

        self . milieu = self . lar / 2

        self . a = 0.0

        self . col = 0

        self . arret = 1

        self . x , self . y = self . milieu + self . rayon * sin ( 0.1 ), self . milieu + self . rayon * cos ( 0.1 )

        self . cercle = self . can . create_oval ( self . lar / 2 - 10 , self . lar - 10 , self . lar + 10 ,   self . lar - 10 , fill = cl [ 0 ])

        self . can . coords ( self . cercle , self . x - 20 , self . y - 20 , self . x + 20 , self . y + 20 )      

    def run ( self ):

        self . arret = 1

        self . tourne ()

    def tourne ( self ):    

        self . a += .01

        a = self . a

        self . col = self . col + 1

        self . x , self . y = self . milieu + self . rayon * sin ( a ), self . milieu + self . rayon * cos ( a )

        self . can . itemconfigure ( self . cercle , fill = cl [ self . col % 5 ])

        dim = lg [ self . col % 5 ]

        self . can . coords ( self . cercle , self . x - dim , self . y - dim , self . x + dim , self . y + dim )

        if self . arret == 1 :

            self . fenetre . after ( 50 , self . tourne )

    def stop ( self ):

        self . arret = 0

class Application ():

  def __init__ ( self , fenetre , largeur ):

      self . fenetre = fenetre

      self . lar = largeur

      self . num = 0

      self . can = Canvas ( width = self . lar , height = self . lar , bg = 'light blue' , borderwidth = 0 )

      self . can . grid ( row = 0 , column = 0 , columnspan = 2 )

      self . tb = Balle ( self . fenetre , self . can , self . lar )

      self . B = Button ( self . fenetre , text = 'TOURNER' , font = fd , command = self . tourner )

      self . B . grid ( column = 0 , row = 1 )

      self . C = Button ( self . fenetre , text = 'STOP' , font = fd , command = self . arreter )

      self . C . grid ( column = 1 , row = 1 )

  def tourner ( self ):

      self . num = self . num + 1

      if self . num == 1 :

          self . tb . run ()

  def arreter ( self ):

      self . num = 0

      self.tb.stop()

largeur=600

hauteur=700

fenetre=Tk()

taille=str(largeur)+'x'+str(hauteur)

fenetre.geometry(taille)

fenetre.configure(bg='green')

d=Application(fenetre,largeur)

fenetre.mainloop()

.

VIDEO melange

.

html video player by EasyHtml5Video.com v4.0

.

CODE python melange.py

.

.

melange.py

 

 

from tkinter import *

from math import *

from time import *

titre = "animation"

fd = 'verdana 25 bold'

fdg = 'vedana 55 bold'

cl =[ 'red' , 'hot pink' , 'deep pink' , 'pink' , 'deep pink' , 'hot pink' ]

lg =[ 20 , 23 , 26 , 30 , 26 , 23 ]

class Balle ():

    def __init__ ( self , fenetre , can , largeur ):

        self . fenetre = fenetre

        self . can = can

        self . lar = largeur

        self . rayon = self . lar / 2 - 35

        self . rayon1 = self . lar / 2 - 45

        self . milieu = self . lar / 2

        self . a = 0.0

        self . col = 0

        self . arret = 1

        liste =[]

        for i in range ( 6 ):

            liste . append ( self . can . create_text ( self . milieu , 30 , text = chr ( 9856 + i ), font = fdg , fill = 'blue' ))

        self . objet = liste

        self . b = 10.0

        self . x , self . y = self . milieu + self . rayon * sin ( 0.1 ), self . milieu + self . rayon * cos ( 0.1 )

        self . cercle = self . can . create_oval ( self . lar / 2 - 10 , self . lar - 10 , self . lar + 10 ,   self . lar - 10 , fill = cl [ 0 ])

        self . can . coords ( self . cercle , self . x - 30 , self . y - 30 , self . x + 30 , self . y + 30 )      

    def run ( self ):

        self . arret = 1

        self . tourne ()

    def tourne ( self ):    

        self . b += .01  

        b = self . b       

        self . a += .05

        a = self . a

        self . col = self . col + 1

        self . x , self . y = self . milieu + self . rayon * sin ( a ), self . milieu + self . rayon * cos ( a )

        self . can . itemconfigure ( self . cercle , fill = cl [ self . col % 5 ])

        dim = lg [ self . col % 5 ]

        self . can . coords ( self . cercle , self . x - dim , self . y - dim , self . x + dim , self . y + dim )

        self . x , self . y = self . milieu + self . rayon1 * sin ( b ), self . milieu + self . rayon1 * cos ( b )

for i in range ( 6 ):

            self . x , self . y = self . milieu + self . rayon1 * sin ( b + i * 10 ), self . milieu + self . rayon1 * cos ( b + i - 10 )

            self . can . coords ( self . objet [ i ], self . x - 20 , self . y - 20 )

        if self . arret == 1 :

            self . fenetre . after ( 50 , self . tourne )

    def stop ( self ):

        self . arret = 0

class Application ():

  def __init__ ( self , fenetre , largeur ):

      self . fenetre = fenetre

      self . lar = largeur

      self . num = 0

      self.can=Canvas(width =self.lar,height =self.lar,bg ='light blue', borderwidth=0)

      self.can.grid(row=0,column=0,columnspan=2)

      self.tb =Balle(self.fenetre,self.can,self.lar)

      self.B=Button(self.fenetre, text ='TOURNER',font=fd, command =self.tourner)

      self.B.grid(column=0,row=1)

      self.C=Button(self.fenetre, text ='STOP',font=fd, command =self.arreter)

      self.C.grid(column=1,row=1)

  def tourner(self):

      self.num=self.num+1

      if self.num==1:

          self.tb.run()

  def arreter(self):

      self.num=0

      self.tb.stop()

largeur=600

hauteur=700

fenetre=Tk()

taille=str(largeur)+'x'+str(hauteur)

fenetre.geometry(taille)

fenetre.configure(bg='green')

d=Application(fenetre,largeur)

fenetre.mainloop()

.

VIDEO collision

.

html video code by EasyHtml5Video.com v4.0
<

.

CODE python collision.py

.

.

collision.py

from tkinter import *

from math import *

from time import *

titre = "animation"

f0 = 'verdana 1'

fu = 'verdana 10'

fd = 'verdana 20 bold'

fdg = 'vedana 58 bold'

cl =[ 'red' , 'hot pink' , 'deep pink' , 'pink' , 'deep pink' , 'hot pink' ]

lg =[ 30 , 33 , 36 , 40 , 36 , 33 ]

lgp =[ 1 ,- 30 ,- 60 ,- 80 ,- 50 ,- 30 ]

class Balle ():

    def __init__ ( self , fenetre , can , largeur , Bouton ):

        self . fenetre = fenetre

        self . can = can

        self . lar = largeur

        self . D1 = Bouton

        self . rayon = self . lar / 2 - 35

        self . rayon1 = self . lar / 2 - 45

        self . milieu = self . lar / 2

        self . a = 0.0

        self . col = 0

        self . arret = 1

        self . resultat = ''

        liste =[]

        for i in range ( 6 ):

            liste . append ( self . can . create_text ( self . milieu , 30 , text = chr ( 9861 - i ), font = fdg , fill = 'blue' ))

        self . objet = liste

        self . b = 10.0

        self . x , self . y = self . milieu + self . rayon * sin ( 0.1 ), self . milieu + self . rayon * cos ( 0.1 )

        self . cercle = self . can . create_oval ( self . lar / 2 - 10 , self . lar - 10 , self . lar + 10 ,   self . lar - 10 , fill = cl [ 0 ])

        self . can . coords ( self . cercle , self . x - 30 , self . y - 30 , self . x + 30 , self . y + 30 )      

    def run ( self ):

        self . arret = 1

        self . tourne ()

    def tourne ( self ):    

        self . b += .02  

        b = self . b       

        self . a += .05

        a = self . a

        self . col = self . col + 1

        dim1 = lgp [ self . col % 5 ]

        self . x , self . y = self . milieu + ( self . rayon + dim1 )* sin ( a ), self . milieu +( dim1 + self . rayon )* cos ( a )

        self . can . itemconfigure ( self . cercle , fill = cl [ self . col % 5 ])

        dim = lg [ self . col % 5 ]

        self . can . coords ( self . cercle , self . x - dim , self . y - dim , self . x + dim , self . y + dim )

        x , y , x1 , y1 = self . x - dim , self . y - dim , self . x + dim , self . y + dim

        self . x , self . y = self . milieu + self . rayon1 * sin ( b ), self . milieu + self . rayon1 * cos ( b )

        for i in range ( len ( self . objet )):

            if i % 2 == 0 : self . x , self . y = self . milieu + self . rayon1 * cos ( b + i * 7 ), self . milieu + self . rayon1 * sin ( b + i * 7 )

            else : self . x , self . y = self . milieu + self . rayon1 *(- cos ( b + i * 7 )), self . milieu + self . rayon1 *( sin ( b + i * 7 ))

            if x < self . x < x1 and y1 > self . y > y and i == len ( self . objet )- 1 :

                self . can . delete ( self . objet [ i ])

                if len ( self . objet )== 1 : self . arret = 0

                del self.objet[i]

                if i==5:

                    self.D1.config(bg='white')

                    self.D1.config(font=fdg)

                    self.resultat=self.resultat+chr(9861-i)

                else:self.resultat=self.resultat+'\n'+chr(9861-i)

                self.D1.config(text=self.resultat)          

            else:self.can.coords(self.objet[i], self.x-20, self.y-20)

        if self.arret==1:self.fenetre.after(50,self.tourne)

    def stop(self):

        self.arret=0

class Application():

  def __init__(self,fenetre,largeur,hauteur):

      self.fenetre=fenetre

      self.lar=largeur

      self.num=0

      self.can=Canvas(width =self.lar,height =self.lar,bg ='light blue')

      self.can.grid(row=0,column=0,rowspan=6,columnspan=2)

      self.B=Button(self.fenetre,text ='CAPTURE',font=fd,command =self.tourner)

      self.B.grid(column=0,row=6)

      mes="La boule doit capturer\ndans l'ordre les dés"

      self.C=Button(self.fenetre, text =mes,font=fu,fg='blue',bg='white')

      self.C.grid(column=1,row=6)

      self.D1=Button(self.fenetre, text ='',font=f0,fg='blue',bg='green')

      self.D1.grid(column=2,row=0,rowspan=6)

      self.tb =Balle(self.fenetre,self.can,self.lar,self.D1)

  def tourner(self):

      self.num=self.num+1

      if self.num==1:self.tb.run()

  def arreter(self):

      self.num=0

      self.tb.stop()

largeur,hauteur=600,700

fenetre=Tk()

taille=str(hauteur)+'x'+str(hauteur)

fenetre.geometry(taille)

fenetre.configure(bg='green')

d=Application(fenetre,largeur,hauteur)

fenetre.mainloop()

 

educationdunumerique.fr. Tous  droits réservés. D Pérarnaud Limoges.