你可以在 python tkinter 中更改小部件的父级吗?

2022-01-18 00:00:00 python tkinter widget frames parents

问题描述

有没有办法改变一个小部件(在这种情况下是 ttk.frame)的父级?我在小部件 .config 中找不到任何要使用的关键字.这在 python tkinter 中是不可能的吗?我想要的功能是在我的 tkk.notebook 小部件中获取我当前的框架,当我双击选项卡时,将所有内容都放在选项卡的框架中,移动到它自己单独的 TopLevel 窗口.这样,用户可以在处理另一个选项卡时对该选项卡进行视觉参考.如果没有我要询问的框架功能,我想不出任何其他方式来实现这一点.也许如果有人能绕过这个问题,我就不需要担心父小部件的功能了.

Is there any way to change a widget's (ttk.frame in this case) parent? I can't find any keywords to use in the widgets .config. Is this not possible in python tkinter? What I'd like functionally is to take my current frame in my tkk.notebook widget, and when I double click the tab, to have everything in the frame of the tab, move to it's own separate TopLevel window. This way the user can have a visual reference to that tab while working on another tab. I couldn't think of any other way to have this happen without the frame functionality I'm asking about. Perhaps if anyone can circumvent this issue, I won't need to worry about parent widget capabilities.

干杯,克里斯


解决方案

An 旧帖 byFredrik Lundh(Tkinter 的作者)建议无法更改小部件的父级.

An old post by Fredrik Lundh (the Tkinter author) suggests that it isn't possible to change a widget's parent.

相关文章