#othello projet prog
from tkinter import *
from random import randrange
#interface graphique
def couleurAlea():
global couleur
alea =['yellow','cyan','blue','green','grey','purple','orange','pink','dark green','red']
c = randrange(10)
couleur = alea[c]
can1.configure(bg=couleur)
def creerTable():
global x1, y1, x2, y2
v=0
h=0
while (v < 9) : # verticales
can1.create_line(x1,y1,x2,y2, width = 5 , fill='black')
x1 = x1 + 70
x2 = x2 + 70
v = v + 1
while (h < 9) : #horizontales
if( h == 0) :
x1, y1, x2, y2 = 700, 565, -700, 565
can1.create_line(x1,y1,x2,y2, width = 5 , fill='black')
y1 = y1 - 70
y2 = y2 - 70
h = h + 1
def detruireRegles():
fen2.destroy
bou3.configure(state=NORMAL)
def regles():
bou3.configure(state=DISABLED)
fen2 = Tk()
fen2.configure(height=500,width=500)
tex2 = Label(fen2, text='REGLES DU JEU',fg='blue',height=0,width=0)
tex2.pack(side=TOP)
txtreg = Label(fen2, text='Othello est un jeu de stratégie à deux joueurs : Noir et Blanc. Il se joue sur un plateau\n unicolore de 64 cases, 8 sur 8, appelé othellier. Ces joueurs disposent de 64 pions\nbicolores, un cote et blancs de l autre. Par commodite, chaque joueur a devant\nlui 32 pions mais ils ne lui appartiennent pas et il doit en donner à son adversaire si\ncelui-ci n en a plus. Un pion est noir si sa face noire est visible et blanc si sa face\nblanche est sur le dessus. ',fg='black')
txtreg.pack()
bou5 = Button(fen2, text='Fermer fenetre', bg='orange', command = fen2.destroy) # doit utiliser detruireRegles : bug le bouton Regles ne se desactive pas com prevu apres lavoir clique
bou5.pack(side=BOTTOM)
x1, y1, x2, y2 = 5, 582, 5 , -582 # coordonees des droites formant la table
fen1 = Tk()
can1 = Canvas(fen1,bg='dark green',height=566.2,width=566.2)
can1.pack(side=LEFT)
tex1 = Label(fen1, text='Bienvenue dans othello!', fg='blue')
tex1.pack()
bou1 = Button(fen1, text='Nouvelle Partie',command = creerTable)
bou1.pack()
bou2 = Button(fen1, text='Changer couleur plateau',command = couleurAlea)
bou2.pack()
bou3 = Button(fen1, text='Regles du jeu', command = regles)
bou3.pack()
bou4 = Button(fen1, text='Quitter',command = fen1.destroy)
bou4.pack()
fen1.mainloop()
What i want is this line :
bou5 = Button(fen2, text='Fermer fenetre', bg='orange', command = fen2.destroy)
(in my 4th function)
i want this button to close WIndow 2 and set NORMAL state on button3 with is a window defined in the main program. Probmel is that if i put ( command = detruireRegles ) #(my second fonction)
it says that fen2 is not defined. SO that means i would need to put 2 commands in the command field but i don't know if there is another way then making a function and this one here for me is not working with this methods.
Thanks for your help. Stef


Sign In
Create Account

Back to top









