如何在 Tkinter 中打开多个窗口 [英] How to open multiple windows in Tkinter

查看:65
本文介绍了如何在 Tkinter 中打开多个窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am working on GUI Project in Python using Tkinter,I want to open Multiple Windows in GUI at a time each operating individually.Not one after another i.e;it should show the new form you are displaying but it should enable you to go back and use the controls in the Main Form .But I getting access to mainform only when the New Form is Closed.

如何实现多个表单?

推荐答案

创建根窗口后,其他窗口应该是 顶级.

After creating the root window, other windows should be instances of 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()

这篇关于如何在 Tkinter 中打开多个窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆