本文整理汇总了Python中tkinter.Frame.grid_remove方法的典型用法代码示例。如果您正苦于以下问题:Python Frame.grid_remove方法的具体用法?Python Frame.grid_remove怎么用?Python Frame.grid_remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.Frame
的用法示例。
在下文中一共展示了Frame.grid_remove方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: fen_info
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import grid_remove [as 别名]
#.........这里部分代码省略.........
self.f_ordi.grid(row=40, columnspan=5, padx=5, pady=5)
Label(self.f_ordi, text="Ordinateur = Colosse", font=("Arial", 12), fg="#0080FF")\
.grid(row=1, column=0, sticky=E, padx = 5, pady = 5)
self.pion_ordi = Label(self.f_ordi, text="| Pion de l'ordinateur = O",
font=("Arial", 12), fg="#0080FF")
self.pion_ordi.grid(row=1, column=2)
separateur(20).grid(row=50,columnspan=5)
# Sélection de la force de l'ordinateur
self.choixForce = IntVar()
self.f1 = Radiobutton(self, indicatoron=0, width = 20,
padx = 20, text="Facile", variable=self.choixForce, value=1, command=self.define_choix)
self.f1.select()
self.f1.grid(row=60, columnspan=5)
self.f2 = Radiobutton(self, indicatoron=0, width = 20,
padx = 20, text="Moyen", variable=self.choixForce, value=2, command=self.define_choix)
self.f2.grid(row=61, columnspan=5)
self.f3 = Radiobutton(self, indicatoron=0, width = 20,
padx = 20, text="Difficile", variable=self.choixForce, value=3, command=self.define_choix)
self.f3.grid(row=62, columnspan=5)
separateur(40).grid(row=70, column=0)
#Button pour démarrer la partie
self.bt_start = Button(text="Démarrer", font=("Arial", 12), fg="green", command=self.demarrer_jeu)
self.bt_start.grid(row=80, columnspan=5)
def define_choix(self):
"""
Fonction qui active ou désactive le nom du joueur 2 selon si on joue contre l'ordinateur ou contre
un autre joueur
"""
if self.choixJoueur.get()==1:
self.nom_joueur2.delete(0, END)
self.nom_joueur2["state"]="disabled"
self.f1["state"]="normal"
self.f2["state"]="normal"
self.f3["state"]="normal"
self.f_j2.grid_remove()
self.f_ordi.grid(row=40, columnspan=5, padx=5, pady=5)
elif self.choixJoueur.get()==2:
self.nom_joueur2["state"]="normal"
self.f1["state"]="disabled"
self.f2["state"]="disabled"
self.f3["state"]="disabled"
self.f_j2.grid(row=40, columnspan=5, padx=5, pady=5)
self.f_ordi.grid_remove()
def choix_pion(self):
# Définition des pions
if self.sel_pion.get()==1:
self.pion1="X"
self.pion2="O"
self.label_pion2["text"]="Pion Joueur 2 = {}".format(self.pion2)
self.pion_ordi["text"]="| Pion de l'ordinateur = {}".format(self.pion2)
else:
self.pion1="O"
self.pion2="X"
self.label_pion2["text"]="Pion Joueur 2 = {}".format(self.pion2)
self.pion_ordi["text"]="| Pion de l'ordinateur = {}".format(self.pion2)
def demarrer_jeu(self):
"""
Démarrer la partie avec les informations saisie. Afficher le plateau
"""
if self.choixJoueur.get()==1:
type2 = "Ordinateur"
if self.nom_joueur1.get()!='':
j1 = self.nom_joueur1.get()
j2 = "Colosse"
else:
j1 = "Joueur 1"
j2 = "Colosse"
elif self.choixJoueur.get()==2:
type2 = "Personne"
if self.nom_joueur1.get()!='' and self.nom_joueur2.get()!='':
j1 = self.nom_joueur1.get()
j2 = self.nom_joueur2.get()
elif self.nom_joueur1.get()=='':
j1 = "Joueur 1"
if self.nom_joueur2.get()=='':
j2 = "Joueur 2"
else:
j2 = self.nom_joueur2.get()
else:
j1 = self.nom_joueur1.get()
if self.nom_joueur2.get()=='':
j2 = "Joueur 2"
else:
j2 = self.nom_joueur2.get()
p1 = self.pion1
p2 = self.pion2
force = self.choixForce.get()
self.destroy()
ma_fenetre = Fenetre(j1, j2, type2, p1, p2, force)
ma_fenetre.mainloop()
示例2: __init__
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import grid_remove [as 别名]
#.........这里部分代码省略.........
Radiobutton(self.frame1, text='B', command=lambda: self.activate_b(1), value=0),
Radiobutton(self.frame1, text='B', command=lambda: self.activate_b(2), value=0),
Radiobutton(self.frame1, text='B', command=lambda: self.activate_b(3), value=0),
Radiobutton(self.frame2, text='B', command=lambda: self.activate_b(4), value=0),
Radiobutton(self.frame2, text='B', command=lambda: self.activate_b(5), value=0),
Radiobutton(self.frame2, text='B', command=lambda: self.activate_b(6), value=0),
Radiobutton(self.frame2, text='B', command=lambda: self.activate_b(7), value=0)]
index = 0
for each in self.b:
each.grid(row=index % 4, column=3)
each.config(width=4, height=2, indicatoron=0, variable=self.v[index], font=('Lucida Console', 30))
each.config(bg='SkyBlue4', activebackground='midnight blue', selectcolor='midnight blue', fg='white')
each.config(activeforeground='white')
index += 1
self.end_image = PhotoImage(file="img/no.png").subsample(x=6, y=6)
self.end_button = [Radiobutton(self.frame1, image=self.end_image, command=lambda: self.end(0)),
Radiobutton(self.frame1, image=self.end_image, command=lambda: self.end(1)),
Radiobutton(self.frame1, image=self.end_image, command=lambda: self.end(2)),
Radiobutton(self.frame1, image=self.end_image, command=lambda: self.end(3)),
Radiobutton(self.frame2, image=self.end_image, command=lambda: self.end(4)),
Radiobutton(self.frame2, image=self.end_image, command=lambda: self.end(5)),
Radiobutton(self.frame2, image=self.end_image, command=lambda: self.end(6)),
Radiobutton(self.frame2, image=self.end_image, command=lambda: self.end(7)),
]
index = 0
for each in self.end_button:
each.grid(row=index % 4, column=5)
each.config(value=2, variable=self.v[index], indicatoron=0)
each.config(bg='brown3', activebackground='brown4')
index += 1
def make_frame(self):
self.frame1.grid(row=2, column=0, rowspan=5)
self.frame2.grid(row=2, column=1, rowspan=5)
self.end_all_button.grid(row=1, column=0, columnspan=2)
row = 0
for each in self.lightsA:
each.grid(row=row % 4, column=1, padx=20, pady=20)
row += 1
row = 0
for each in self.lightsB:
each.grid(row=row % 4, column=4, padx=20, pady=20)
row += 1
def delete_frame(self):
self.frame1.grid_remove()
self.frame2.grid_remove()
self.end_all_button.grid_remove()
for each in self.lightsA:
each.grid_remove()
for each in self.lightsB:
each.grid_remove()
def activate_a(self, number):
pin_number = 65 + number
pin_opposite = 80 - number
if self.v[number].get() == 1:
self.lightsA[number].set_state(True)
self.lightsB[number].set_state(False)
wiringpi.digitalWrite(pin_number, 1)
wiringpi.digitalWrite(pin_opposite, 0)
def activate_b(self, number):
pin_number = 80 - number
pin_opposite = 65 + number
if self.v[number].get() == 0:
self.lightsA[number].set_state(False)
self.lightsB[number].set_state(True)
wiringpi.digitalWrite(pin_number, 1)
wiringpi.digitalWrite(pin_opposite, 0)
def end(self, number):
pin_number = 65 + number
pin_opposite = 80 - number
wiringpi.digitalWrite(pin_number, 0)
wiringpi.digitalWrite(pin_opposite, 0)
self.v[number].set(3)
self.lightsA[number].set_state(False)
self.lightsB[number].set_state(False)
def end_all(self):
number = 0
while number < 8:
self.end(number)
number += 1