Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/312.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/apache-spark/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python TkInter问题:删除上一个按下按钮的主体?_Python_Tkinter - Fatal编程技术网

Python TkInter问题:删除上一个按下按钮的主体?

Python TkInter问题:删除上一个按下按钮的主体?,python,tkinter,Python,Tkinter,所以我正在为学校学习TkInter,我必须用不同的选项来编写我的课程表。它进行得很顺利,但我遇到了一个问题,它没有替换文本,而是写在上面 每当我按下按钮时,都会显示文本,但如果我按下另一个按钮,它会在显示的文本上显示文本,而不是替换文本。我正在做标签上的所有文字,因为它起作用了。。尝试了文本和所有这些,但给我带来了一些标签修复的其他问题。不过,我还是新手,所以如果标签有任何修正,我会欢迎的,但如果修正是用文本替换每个标签,那么我只想知道具体如何。谢谢 这是我的密码: from tkinter i

所以我正在为学校学习TkInter,我必须用不同的选项来编写我的课程表。它进行得很顺利,但我遇到了一个问题,它没有替换文本,而是写在上面

每当我按下按钮时,都会显示文本,但如果我按下另一个按钮,它会在显示的文本上显示文本,而不是替换文本。我正在做标签上的所有文字,因为它起作用了。。尝试了文本和所有这些,但给我带来了一些标签修复的其他问题。不过,我还是新手,所以如果标签有任何修正,我会欢迎的,但如果修正是用文本替换每个标签,那么我只想知道具体如何。谢谢

这是我的密码:

from tkinter import *

class Asignatura:
  def __init__(self, dia, salon, h_comienzo, h_fin, curso, libre):
    self.dia = dia
    self.salon = salon
    self.h_comienzo = h_comienzo
    self.h_fin = h_fin
    self.curso = curso
    self.libre = libre

  def minutos(self, curso):
    minutes = self.h_fin[curso] % 100
    self.hora = (((self.h_fin[curso] - self.h_comienzo[curso]) // 100)*60) + minutes
    return(self.hora)


#en dos en dos
lu_mie = Asignatura("LW", "319", ["1800", "2000"], ["1955", "2155"], ["COMP 2501", "COMP 2400"],  "700 - 1800 : LIBRE")
mar_jue = Asignatura("MJ", "", "", "", ["CLASE ONLINE GEPE 4040", "CLASE ONLINE MATH 2251"],  "700 - 2200 : LIBRE")
vie_sab_dom = Asignatura("VSD", "", "", "", "", "700 - 2200 : LIBRE")




class TheGUI:
    def __init__(self, master):
        self.master = master
        master.title("-- PROGRAMA DE CLASES --")
        master.geometry('550x250')

        blankspace=StringVar()
        blankspace.set("")

        def ProgComp():
            self.label = Label(master, text=lu_mie.dia + " : " + lu_mie.libre).grid(row=2,column=3, sticky=E)
            self.label = Label(master, text=lu_mie.h_comienzo[0]+ " - "+ lu_mie.h_fin[0]+ ": "+ lu_mie.curso[0]+ " SALON: "+ lu_mie.salon).grid(row=3,column=3, sticky=E)
            self.label= Label(master, text= lu_mie.h_comienzo[1]+ " - "+ lu_mie.h_fin[1]+ ": "+ lu_mie.curso[1]+ " SALON: "+ lu_mie.salon).grid(row=4,column=3, sticky=E)
            self.label= Label(master, text= mar_jue.dia+ ": "+ mar_jue.libre+ "\n     "+ mar_jue.curso[0]+ "\n     "+ mar_jue.curso[1]).grid(row=5,column=3, sticky=E)
            self.label= Label(master, text=vie_sab_dom.dia+ ": "+ vie_sab_dom.libre).grid(row=6,column=3, sticky=E)

        def UnDia():
            #lunes y miercoles
            def luMieButton():
                self.label = Label(master, text=lu_mie.dia + " : " + lu_mie.libre).grid(row=1,column=4, sticky=W)
                self.label = Label(master, text=lu_mie.dia + " : " + lu_mie.libre).grid(row=2,column=4, sticky=W)
                self.label = Label(master, text=lu_mie.h_comienzo[0]+ " - "+ lu_mie.h_fin[0]+ ": "+ lu_mie.curso[0]+ " SALON: "+ lu_mie.salon).grid(row=3,column=4, sticky=W)
                self.label= Label(master, text= lu_mie.h_comienzo[1]+ " - "+ lu_mie.h_fin[1]+ ": "+ lu_mie.curso[1]+ " SALON: "+ lu_mie.salon).grid(row=4,column=4,sticky=W)

            #martes y jueves
            def marJueButton():
                self.label= Label(master, text= mar_jue.dia+ ": "+ mar_jue.libre+ "\n     "+ mar_jue.curso[0]+ "\n     "+ mar_jue.curso[1]).grid(row=1,column=4, sticky=W)
            #fin de semana
            def vieSabDomButton():
                self.label= Label(master, text= vie_sab_dom.dia+ ": "+ vie_sab_dom.libre).grid(row=1,column=4,sticky=W)
            #butones

            self.lunesDia = Button(master, text="LUNES", command=luMieButton).grid(row=1,column=100,sticky=E)
            self.martesDia = Button(master, text="MARTES", command=marJueButton).grid(row=2, column=100, sticky=E)
            self.miercolesDia = Button(master, text="MIERCOLES", command=luMieButton).grid(row=3,column=100,sticky=E)
            self.juevesDia = Button(master, text="JUEVES", command=marJueButton).grid(row=4, column=100, sticky=E)
            self.viernesDia = Button(master, text="VIERNES", command=vieSabDomButton).grid(row=5, column=100, sticky=E)
            self.sabadoDia = Button(master, text="SABADO", command=vieSabDomButton).grid(row=6, column=100, sticky=E)
            self.domingoDia = Button(master, text="DOMINGO", command=vieSabDomButton).grid(row=7, column=100, sticky=E)

        def Disponibilidad():
            pass






        self.progCompleto = Button(master, text="Programa Completo", command=ProgComp).grid(row=1, column=0, sticky=W)
        self.diaEspecifico = Button(master, text="Programa de un dia", command=UnDia).grid(row=2, column=0, sticky=W)
        self.horaDisponible = Button(master, text="Verificar Disponibilidad", command=Disponibilidad).grid(row=3, column=0, sticky=W)
        self.exit = Button(master, text="Close", command=master.destroy).grid(row=4, column=0, sticky=W)

root = Tk()
my_gui = TheGUI(root)
root.mainloop()
首先你必须理解首先你必须理解