【问题标题】:How to open multiple windows in Tkinter如何在 Tkinter 中打开多个窗口
【发布时间】:2015-10-09 04:49:38
【问题描述】:

我正在使用 Tkinter 在 Python 中进行 GUI 项目,我想一次在 GUI 中打开多个窗口,每个窗口都单独运行。不是一个接一个,即;它应该显示您正在显示的新表单,但它应该使您能够返回并使用主窗体中的控件。但我只有在新窗体关闭时才能访问主窗体。

如何获得多个表单?

【问题讨论】:

    标签: python-2.7 tkinter


    【解决方案1】:

    创建根窗口后,其他窗口应该是Toplevel的实例。

    import Tkinter as tk
    
    root = tk.Tk()
    tk.Label(root, text="this is the root window").pack()
    root.geometry("200x200")
    for i in range(4):
        window = tk.Toplevel()
        window.geometry("200x200")
    
        tk.Label(window, text="this is window %s" % i).pack()
    
    root.mainloop()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-08-07
      • 2022-01-22
      • 2013-09-18
      • 2018-05-11
      • 2018-11-17
      • 2021-06-27
      • 2018-05-18
      • 1970-01-01
      相关资源
      最近更新 更多