Python 在tkinter应用程序开发中,为什么我的代码不提供任何输出?

Python 在tkinter应用程序开发中,为什么我的代码不提供任何输出?,python,tkinter,Python,Tkinter,我正在尝试使用Tkinter Python开发一个小部件。它应该分两个阶段将数据作为用户的输入,然后根据给定的输入进一步处理。我的代码根本不提供任何输出。我是Python新手 这是我的密码: from tkinter import * def f_step(): global txt_1 global txt_2 global v0 window=Tk() txt_1=StringVar() Label(window,text="DB/rs

我正在尝试使用Tkinter Python开发一个小部件。它应该分两个阶段将数据作为用户的输入,然后根据给定的输入进一步处理。我的代码根本不提供任何输出。我是Python新手

这是我的密码:


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!
'''


您的代码没有给出任何输出,因为您还没有调用任何函数。 您只定义了函数

尝试在代码末尾调用
f_step()


希望这有帮助

首先,您必须运行
DelUser()
当我运行
DelUser()
f_步骤()
时,您的代码只会给我错误-您使用了一些变量(如
f
窗口
)您不将其作为参数发送给代码,或者使用局部变量
window
,它无法在其他函数中访问它来销毁它。也许可以使用类来将所有内容保持在一起,并使用
self.
而不是
global
。但首先在控制台中运行它,看看是否会收到错误消息——输出任何东西都可能是您的主要问题。顺便问一下:您希望得到什么输出?您不使用任何
print()
来显示输出。如果我选择
yes
no
,它只显示带有一些标签的窗口。如果我没有选择
yes
no
,那么我就不会得到窗口。创建我们可以运行的最小工作代码。谢谢你们。现在我知道问题出在哪里了。