Tkinter example code for multiple windows, why won't buttons load correctly?

前端 未结 5 1914
独厮守ぢ
独厮守ぢ 2020-12-02 07:44

I am writing a program which should:

  1. Open a window with the press of a button.
  2. Close the newly opened window with the press of another button.
5条回答
  •  既然无缘
    2020-12-02 08:37

    What you could do is copy the code from tkinter.py into a file called mytkinter.py, then do this code:

    import tkinter, mytkinter
    root = tkinter.Tk()
    window = mytkinter.Tk()
    button = mytkinter.Button(window, text="Search", width = 7,
                                   command=cmd)
    button2 = tkinter.Button(root, text="Search", width = 7,
                                   command=cmdtwo)
    

    And you have two windows which don't collide!

提交回复
热议问题