[Tkinter-discuss] I am aking again

Blujacker (sent by Nabble.com) lists at nabble.com
Tue Jan 31 15:34:38 CET 2006


I am here again.I am sure you can help me.I need any function like destroy which can delete window.The programm you can see on http://poradna.programujte.com/viewtopic.php?t=973
If you run in, You will see a menu.If you open "rozrh hodin" and then you open "prumer" you will see 3 windows.How to delete 2 old windows?I would like see all timees only one window:
Here is the programm:


from Tkinter import *
import sys

okno=Tk()






zaznam=0.000
man=0.000

def znic():
    okno.destroy
   
def prumery():
    top=Toplevel()
    okno.destroy
    def dement1():
        global zaznam,man,dement1
        zaznam=zaznam+1.000
        man=man+1.000
    def dement2():
        global zaznam,man,dement2
        zaznam=zaznam+2.000
        man=man+1.00
    def dement3():
        global zaznam,man,dement3
        zaznam=zaznam+3.000
        man=man+1.000
    def dement4():
        global zaznam,man,dement4
        zaznam=zaznam+4.000
        man=man+1.000
    def dement5():
        global zaznam,man,dement5
        zaznam=zaznam+5.000
        man=man+1.000
    def money():
        global zaznam,man,money
        prumer1.configure(text=zaznam/man)
   
    prvni=Button(top, text="1",command=dement1)
    prvni.grid(row=1, column=0)

    druhy=Button(top, text="2",command=dement2)
    druhy.grid(row=2, column=0)

    treti=Button(top, text="3",command=dement3)
    treti.grid(row=3,column=0)

    ctvrty=Button(top, text="4",command=dement4)
    ctvrty.grid(row=4,column=0)

    paty=Button(top, text="5",command=dement5)
    paty.grid(row=5,column=0)
               
    prumer=Button(top, text="Prumer",command=money)
    prumer.grid(row=1, column=2)

    prumer1=Label(top, text="Prumer:")
    prumer1.grid(row=4, column=2)
   
   

    menubar = Menu(top)

    # create a pulldown menu, and add it to the menu bar
    filemenu = Menu(menubar, tearoff=0)
    filemenu.add_command(label="Rozvrh", command=(veci))
    filemenu.add_separator()
    menubar.add_cascade(label="Rozvrh hodin", menu=filemenu)

    # create more pulldown menus
    editmenu = Menu(menubar, tearoff=0)
    editmenu.add_command(label="Prumer", command=prumery)
    menubar.add_cascade(label="Prumer", menu=editmenu)



    helpmenu = Menu(menubar, tearoff=0)
    helpmenu.add_command(label="Exit", command=okno.destroy)
    helpmenu.add_command(label="save", command=Save)
    menubar.add_cascade(label="Exit", menu=helpmenu)



    top.config(menu=menubar)
def veci():
    okno.destroy
    top=Toplevel()
    def TV1():
        global tv1,TV1
        free1.configure(text="Telesna vychova;Peter Kuba;Mala telocvicna")
    def M1():
        global m1,M1
        free1.configure(text="Matematika,Hana Rosolova;Ucebna c.37")
    def F1():
        global f1, F1
        free1.configure(text="Fyzika, Hana Rosolova;Ucebna c.42")
    def C1():
        global c1, C1
        free1.configure(text="Cesky jazyk-Literatura;Lenka Necasova;Ucebna c.16")
    def D1():
        global d1,D1
        free1.configure(text="Dejepis;Jan Kvirenc;Ucebna c.35")
    def prm():
        global zaznam
        zaznam=0.000
        man=0.000
    def A1():
        global a1
        free1.configure(text="Anglicky jazyk;Adam Kosik;Ucebna c.41")
    def V():
        global v1,v2
        free1.configure(text="Vytvarna Vychova;Cech Matej;Ucebna c.53")
    def N1():
        global n1
        free1.configure(text="Nemecky jazyk;Pacholikova Marie;Ucebna c.42")
    def M2():
        global m2
        free1.configure(text="Matematika;Hana Rosolova;Ucebna c.45")
    def CH1():
        global c1
        free1.configure(text="Chemie;Buth Stanislav;Ucebna c.24")
    def Z1():
        global z1
        free1.configure(text="Zemepis;Jitka Breitschneiderova;Ucebna c.14")
    def C2():
        global c2
        free1.configure(text="Cesky jazyk;Lenka Necasova;Ucebna c.04")
    def B1():
        global b1
        free1.configure(text="Biologie;Jarmila Ekschlagerova;Ucebna c.32")
    def OV1():
        global ov1
        free1.configure(text="Obcanska vychova;Kadlec Frantisek;Ucebna c.11")
    def N2():
        global n2
        free1.configure(text="Nemecky jazyk;Pacholikova Marie;Ucebna c.42")
    def D2():
        global d2
        free1.configure(text="Dejepis;Jan Kvirenc;Ucebna c.23")
    def M3():
        global m3
        free1.configure(text="Matematika;Hana Rosolova;Ucebna c.26")
    def TV2():
        global tv2
        free1.configure(text="Telesna vychova;Kuba Peter;Posilovna")
    def F2():
        global f2
        free1.configure(text="Fyzika;Hana Rosolova;Ucebna c.42")
    def C3():
        global c3
        free1.configure(text="Cesky jazyk;Lenka Necasova;Ucebna c.04")
    def Z2():
        global z2
        free1.configure(text="Zemepis;Jitka Breitschneiderova;Ucebna c.13")
    def B2():
        global b2
        free1.configure(text="Biologie;Jarmila Ekschlagerova;Ucebna c.34")
    def A2():
        global a2
        free1.configure(text="Anglicky jazyk;Adam Kosik;Ucebna c.53")
    def I():
        i1,i2
        free1.configure(text="Informatika;*** Drbohlavova;Ucebna c.02")
    def A3():
        global a3
        free1.configure(text="Anglicky jazyk;Adam Kosik;Ucebna c.46")
    def N3():
        global n3
        free1.configure(text="Nemecky jazyk;Pacholikova Marie;Ucebna c.36")
    def H():
        global h
        free1.configure(text="Hudebni vychova;Duskova Marie;Ucebna c.54")
    def CH2():
        global ch2
        free1.configure(text="Chemie;Buth Stanislav;Ucebna c.26")
    def M4():
        global m4
        free1.configure(text="Matematika;Hana Rosolova;Ucebna c.41")
    def C4():
        global c4
        free1.configure(text="Cesky jazyk;Lenka Necasova;Ucebna c.12")
    def TV3():
        global tv3
        free1.configure(text="Telesna vychova;Kuba Peter;Velka telocvicna")
    def obed():
        global o1
        free1.configure(text="Pausa na obed.")


    pondeli=Label(top, text="Pondeli", background='white', foreground='red',activeforeground='yellow')
    pondeli.grid(row=1, column=4)         

    utery=Label(top, text="Utery", background='white', foreground='red')
    utery.grid(row=2, column=4)

    streda=Label(top, text="Streda", background='white', foreground='red')
    streda.grid(row=3, column=4)

    ctvrtek=Label(top, text="Ctvrtek", background='white', foreground='red')
    ctvrtek.grid(row=4, column=4)

    patek=Label(top, text="Patek", background='white', foreground='red')
    patek.grid(row=5, column=4)


    hod1=Label(top, text="1.Hodina", background='white', foreground='red')
    hod1.grid(row=0, column=5)

    hod2=Label(top , text="2.Hodina", background='white', foreground='red')
    hod2.grid(row=0, column=6)

    hod3=Label(top, text="3.Hodina", background='white', foreground='red')
    hod3.grid(row=0, column=7)

    hod4=Label(top, text="4.Hodina", background='white', foreground='red')
    hod4.grid(row=0, column=8)

    hod5=Label(top, text="5.Hodina", background='white', foreground='red')
    hod5.grid(row=0, column=9)

    hod6=Label(top, text="6.Hodina", background='white', foreground='red')
    hod6.grid(row=0,column=10)

    hod7=Label(top, text="7.Hodina", background='white', foreground='red')
    hod7.grid(row=0, column=11)

    hod8=Label(top, text="8.Hodina", background='white', foreground='red')
    hod8.grid(row=0, column=12)

    hod9=Label(top, text="9.Hodina", background='white', foreground='red')
    hod9.grid(row=0,column=13)

    hod10=Label(top, text="10.Hodina", background='white', foreground='red')
    hod10.grid(row=0, column=14)

    tv1=Button(top, text="Tv", command=TV1, background='pink',activebackground='yellow')
    tv1.grid(row=1, column=5)

    m1=Button(top, text="M", command=M1, background='red')
    m1.grid(row=1,column=6)

    f1=Button(top, text="F", command=F1, background='brown')
    f1.grid(row=1, column=7)

    c1=Button(top, text="Cj", command=C1, background='blue')
    c1.grid(row=1, column=8)

    d1=Button(top, text="D" , command=D1, background='Black', foreground='white')
    d1.grid(row=1, column=9)                   
                       
    a1=Button(top, text="Aj", command=A1, background='green')
    a1.grid(row=1, column=10)

    v1=Button(top, text="Vv", command=V, foreground='blue')
    v1.grid(row=1, column=12)

    v2=Button(top, text="Vv", command=V, foreground='blue')
    v2.grid(row=1, column=13)

    n1=Button(top, text="Nj", command=N1, background='yellow')
    n1.grid(row=2, column=5)

    m2=Button(top, text="M", command=M2, background='red')
    m2.grid(row=2, column=6)

    ch1=Button(top, text="Ch", command=CH1, background='orange')
    ch1.grid(row=2, column=7)

    z1=Button(top, text="Z", command=Z1, background='grey')
    z1.grid(row=2, column=8)

    c2=Button(top, text="Cj", command=C2, background='blue')
    c2.grid(row=2, column=9)

    b1=Button(top, text="B", command=B1, foreground='red')
    b1.grid(row=2, column=10)

    ov1=Button(top, text="Ov", command=OV1, foreground='green')
    ov1.grid(row=3, column=5)

    n2=Button(top, text="Nj", command=N2, background='yellow')
    n2.grid(row=3, column=6)

    d2=Button(top, text="D", command=D2, background='Black', foreground='white')
    d2.grid(row=3, column=7)

    m3=Button(top, text="M", command=M3, background='red')
    m3.grid(row=3, column=8)

    tv2=Button(top, text="Tv", command=TV2, background='pink')
    tv2.grid(row=3,column=10)

    f2=Button(top, text="F", command=F2, background='brown')
    f2.grid(row=3, column=11)

    c3=Button(top, text="Cj", command=C3, background='blue')
    c3.grid(row=4, column=7)

    z2=Button(top, text="Z", command=Z2, background='grey')
    z2.grid(row=4, column=8)

    b2=Button(top, text="B", command=B2, foreground='red')
    b2.grid(row=4, column=9)

    a2=Button(top, text="Aj", command=A2, background='green')
    a2.grid(row=4, column=11)

    i1=Button(top, text="In", command=I, foreground='orange')
    i1.grid(row=4, column=12)

    i2=Button(top, text="In", command=I, foreground='orange')
    i2.grid(row=4,column=13)

    a3=Button(top, text="Aj", command=A3, background='green')
    a3.grid(row=5,column=5)

    n3=Button(top, text="Nj", command=N3, background='yellow')
    n3.grid(row=5,column=6)

    h=Button(top, text="Hv", command=H, foreground='yellow')
    h.grid(row=5, column=7)

    ch2=Button(top, text="Ch", command=CH2, background='orange')
    ch2.grid(row=5, column=8)

    m4=Button(top, text="M", command=M4, background='red')
    m4.grid(row=5, column=9)

    c4=Button(top, text="Cj", command=C3, background='blue')
    c4.grid(row=5, column=10)

    tv3=Button(top, text="Tv", command=TV3, background='pink')
    tv3.grid(row=5, column=12)
   

     
       
    def hello():
        print "hello!"

    menubar = Menu(top)

    # create a pulldown menu, and add it to the menu bar
    filemenu = Menu(menubar, tearoff=0)
    filemenu.add_command(label="Rozvrh", command=veci)
    filemenu.add_separator()
    menubar.add_cascade(label="Rozvrh hodin", menu=filemenu)

    # create more pulldown menus
    editmenu = Menu(menubar, tearoff=0)
    editmenu.add_command(label="Prumer", command=prumery)
    menubar.add_cascade(label="Prumer", menu=editmenu)



    helpmenu = Menu(menubar, tearoff=0)
    helpmenu.add_command(label="Exit", command=okno.destroy)
    helpmenu.add_command(label="save", command=Save)
    menubar.add_cascade(label="Exit", menu=helpmenu)



    top.config(menu=menubar)


 
   

    #fereeesdfdsfdsf
    free=Label(top, text="Podrobnosti:")
    free.grid(row=1, column=16)

    free1=Label(top, text="")
    free1.grid(row=2, column=16)




def Save(self):
    "Ulozeni dokumentu"
    soubor = file(self.filename,'w')
    soubor.write(self.text.get("1.0",END).encode(KODOVANI))
    soubor.close()

     
   
def hello():
    print "hello!"

menubar = Menu(okno)

# create a pulldown menu, and add it to the menu bar
filemenu = Menu(menubar, tearoff=0)
filemenu.add_command(label="Rozvrh", command=(veci))
filemenu.add_separator()
menubar.add_cascade(label="Rozvrh hodin", menu=filemenu)

# create more pulldown menus
editmenu = Menu(menubar, tearoff=0)
editmenu.add_command(label="Prumer", command=prumery)
menubar.add_cascade(label="Prumer", menu=editmenu)



helpmenu = Menu(menubar, tearoff=0)
helpmenu.add_command(label="Exit", command=okno.destroy)
helpmenu.add_command(label="save", command=Save)
menubar.add_cascade(label="Exit", menu=helpmenu)



okno.config(menu=menubar)




mainloop()
--
View this message in context: http://www.nabble.com/I-am-aking-again-t1033125.html#a2680779
Sent from the Python - tkinter-discuss forum at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20060131/f1d6d4da/attachment-0001.html 


More information about the Tkinter-discuss mailing list