主窗口上的按钮正常,但子窗口按钮无法创建新窗口,如何解决?

主窗口上的按钮可以正常使用,但是创建出来的子窗口上的按钮却无法再创建一个窗口。
以下是源代码


​
import tkinter as tk
import tkinter.font as tf
import os,sys


def run():
    global there
    global novel
    global root_look
    global a
    run = tk.Toplevel()
    run.title('你的文件')
    bookname = tk.Label(run,text=a)
    bookname.pack()
    run.mainloop()
    #这里的函数无法运行
def look():
    root_look = tk.Toplevel()
    root_look.title('选择')
    root_look.geometry("225x100")
    root_look.configure(bg='grey')
    say = tk.Label(root_look,text='请输入文件名:',bg='grey')
    say.grid(row=0)
    ok = tk.Button(root_look,text='确定',command=run)
    #这是出现问题的按钮
    ok.grid(row=1)
    novel = tk.Entry(root_look,bg='grey')
    novel.grid(row=0, column=1)
    a = novel.get()
    root_look.mainloop()
    #问题界面的代码
there = sys.path[0]
root = tk.Tk(className='编辑器')
root.geometry("450x300")
root.configure(bg='grey')
welcome = tk.Label(root, text='编辑器', bg='grey')
welcome.grid(row=0)
Wfont = tf.Font(family='微软雅黑',size=30)
welcome.config(font=Wfont)
run = tk.Button(root,text='查找',command=look)
run.grid(row=0,column=1)
root.mainloop()


​

我期望达成的效果,是所有按钮均可生效。

img


如图,按下按钮后,未产生新的窗口。

修改最后几行run=tk.Button() 的run变量名, 因为此时run变量指向的是这个按钮, 而不是函数。

--snip--
run2 = tk.Button(root,text='查找',command=look)
run2.grid(row=0,column=1)
root.mainloop()

img

img

回调函数和主窗口的btn按钮名重复了,程序不知道你要调用的是哪个。