简体   繁体   中英

In tkinter application development, why does my code not give any output?

I am trying to develop a widget using Tkinter Python. It should take the data as input from user in two stages and then proceed further based on given inputs. My code does not give any output at all. I am new to Python.

Here is my code:


from tkinter import *

def f_step():
    global txt_1
    global txt_2
    global v0

    window=Tk()

    txt_1=StringVar()
    Label(window,text="DB/rst name (without extension)").place(x=10,y=75)
    Entry(window,textvariable=txt_1,width=40).place(x=225,y=75)

    txt_2=StringVar()
    Label(window,text="DB/rst folder path").place(x=10,y=100)
    Entry(window,textvariable=txt_2,width=40).place(x=225,y=100)

    v0=StringVar()
    #v0.set(1)
    Label(window,text="Do you have first node number").place(x=10,y=150)
    Radiobutton(window,text="yes",variable=v0,value="a").place(x=225,y=150)
    Radiobutton(window,text="no",variable=v0,value="b").place(x=350,y=150)

    Button(window,text="Next",command=clicked).place(x=250,y=250)
    window.title('Path operation application')
    window.geometry("500x300+10+10")
    window.mainloop()


def clicked():    
    global db_name
    global fpath
    global aa

    db_name = txt_1.get()
    fpath = txt_2.get()
    aa=v0.get() 
    window.destroy()
    Initiaterun()

def Initiaterun():
    if aa == "a": # Checks to see if you entered the correct data.
        r = Tk() # Opens new window
        r.title(':D')
        r.geometry('150x50') # Makes the window a certain size
        rlbl = Label(r, text='\n[+] with node number operation') # "logged in" label
        rlbl.pack() # Pack is like .grid(), just different
        r.mainloop()
    elif aa == "b":
        r = Tk()
        r.title('D:')
        r.geometry('150x50')
        rlbl = Label(r, text='\n[!] With component file operation')
        rlbl.pack()
        r.mainloop()

def DelUser():
    r.destroy() # Destroys the login window
    f_step() # And goes back to the start!
'''

Your code doesn't give any output because you have not called any functions yet. You have only defined the functions.

Try calling f_step() at the end of the code.

Hope this helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM