Je n'arrive pas à fermer ma fenêtre :(

Fermé
Boulou - Modifié par NHenry le 12/03/2016 à 20:24
 Boulou - 12 mars 2016 à 20:21
Bonjour,

j'ai un petit problème qui me bloque j'essaye de crée une interface pour mon tétris mais quand je veux appuyer sur le bouton jeu de mon interface sommaire je n'arrive pas à fermer cette interface face et ouvrir l'interface jeu....
Il y a surement d'autre petite erreur mais bon voila le gros problème
Help me.... :(

from tkinter import*
from pygame.locals import *
import pygame
import random, os.path
class interface:


    def musique(self):
        pygame.mixer.init(44100, -16,2,2048)
        music = os.path.join('dragonforce.wav')
        pygame.mixer.music.load(music)
        pygame.mixer.music.play(0)

    def stop(self):
        pygame.mixer.music.pause()

    def play(self):
        pygame.mixer.music.play()


    def changer_musique(self):
        pygame.mixer.music.pause()
        music = os.path.join('nirvana.wav')
        pygame.mixer.music.load(music)
        pygame.mixer.music.play(0)

    def laison(self):
        self.fenetre.destroy
        self.interface_jeu

    def interface_jeu(self):
        fenetre = Tk()
        canvas = Canvas(fenetre, width=150, height=120)

        m1 = PanedWindow()
        m1.pack(fill=BOTH, expand=1)

        jeu = Label(m1, background='blue', width=80, height=50)
        m1.add(jeu)

        m2 = PanedWindow(m1, orient=VERTICAL)
        m1.add(m2)

        chrono = Label(m2, background='red', width=15, height=15)
        m2.add(chrono)

        point = Label(m2, background='orange', width=12, height=15)
        m2.add(point)


    def interface_paramètre(self):
        fenetre = Tk()
        can=Canvas(fenetre, width=500, height=200, bg='ivory')
        can.pack(side=TOP, padx=5, pady=5)
        photo = PhotoImage(file="paramètre.gif")
        can.create_image(250, 100, image=photo, anchor=CENTER)
        b1=Button(fenetre, text ='MUSIQUE!', height=1 ,width=15, bg='red',fg='green',font="Courier 30 bold",relief=RAISED, cursor="spider", cammand=self.changer_musique).pack(side=TOP , padx=50, pady=20)
        b2=Button(fenetre, text ='COULEUR!', height=1 ,width=15, bg='red',fg='green',font="Courier 30 bold",relief=RAISED, cursor="spider").pack(side=TOP , padx=50, pady=20)
        b3=Button(fenetre, text ='Validé', height=1 ,width=15, bg='red',fg='green',font="Courier 30 bold",relief=RAISED, cursor="spider").pack(side=BOTH , padx=50, pady=20)

    def interface_Sommaire(self):
        self.fenetre = Tk()
        can=Canvas(self.fenetre, width=500, height=200, bg='ivory')
        can.pack(side=TOP, padx=5, pady=5)
        photo = PhotoImage(file="tetris-logo.gif")
        can.create_image(250, 100, image=photo, anchor=CENTER)

        can2=Canvas(self.fenetre, width=10, height=5, bg='ivory')
        can2.pack(side=TOP, padx=5, pady=5)
        bouton = Checkbutton(can2, text="Stop!",fg='purple',bg='ivory',command=self.stop).pack(side=LEFT , padx=50, pady=20)
        bouton2 = Checkbutton(can2, text="Go!",fg='purple',bg='ivory', command=self.play).pack(side=RIGHT , padx=50, pady=20)

        b1=Button(self.fenetre, text ='Jeu', height=1 ,width=15, bg='red',fg='green',font="Courier 30 bold",relief=RAISED, cursor="spider", command= self.laison).pack(side=TOP , padx=50, pady=20)
        b2=Button(self.fenetre, text ='Paramètre', height=1 ,width=15, bg='purple', fg='red',font="Courier 30 bold",relief=GROOVE, cursor="spraycan", command=self.interface_paramètre).pack(side=TOP , padx=50, pady=20)
        b3=Button(self.fenetre, text ='Fermer', height=1 ,width=15, bg='blue',fg='yellow', font="Courier 30 bold",relief=GROOVE, cursor="trek",command=self.fenetre.destroy).pack(side=BOTTOM , padx=50, pady=20)
        self.fenetre.mainloop()

obj=interface()
obj.musique()
obj.interface_Sommaire()


EDIT : Ajout des balises de code (la coloration syntaxique).
Explications disponibles ici : ICI

Merci d'y penser dans tes prochains messages.
A voir également:

1 réponse

désolé mon copier coller a supprimer les espaces :/
1