Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/328.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
有办法改变吗;。mainloop()';在tkinter中,python?_Python_Tkinter - Fatal编程技术网

有办法改变吗;。mainloop()';在tkinter中,python?

有办法改变吗;。mainloop()';在tkinter中,python?,python,tkinter,Python,Tkinter,我正在做一个带有一些“说明”的小项目,在说明的最后,我问用户是否希望在程序运行时有一个包含说明的窗口。如果答案是“是”,则tkinter代码将运行,并且由于“.mainloop()”的原因,我无法返回菜单。我只有关上窗户才能回来 def open_instructions_window(): def close(): w.destroy() w = tkinter.Tk() w.geometry("550x500") w.title("Ins

我正在做一个带有一些“说明”的小项目,在说明的最后,我问用户是否希望在程序运行时有一个包含说明的窗口。如果答案是“是”,则tkinter代码将运行,并且由于“.mainloop()”的原因,我无法返回菜单。我只有关上窗户才能回来

def open_instructions_window():

    def close():
        w.destroy()

    w = tkinter.Tk()
    w.geometry("550x500")

    w.title("Instructions")
    w.configure(background = "black")

    label_1 = Label(w, text = "Instructions", font = "none 17 bold underline",bg = "black", fg = "brown")
    label_1.grid(row = 1, sticky = W)

    exit_button = Button(w, text = "CLOSE", bg = "brown" ,fg = "white",relief=SUNKEN, command = close)
    exit_button.grid(row = 20, column = 1, sticky = E)

    w.mainloop()# Because of this I couldn't get back to the menu
    menu()

是否有其他方法可以将其放置在运行时,窗口将打开并保持打开状态,并且“menu()”将被执行?

您可以使用Toplevel创建另一个包含指令的窗口。用户可以通过单击按钮打开窗口并关闭它,而不会影响主窗口。查看Jagandeep Singh的示例: