Python-如何在Tkinter窗口中切换帧

时间:2019-02-15 16:23:03

标签: python-3.x tkinter

我想在Tkinter窗口中切换帧,但是上一帧始终在后台可见。

这是我的代码:

from tkinter import *

class frame(Frame):

    def __init__(self,display):
        Frame.__init__(self,display)
        l = Label(self,text="frame1")
        l.pack()

class frame2(Frame):

    def __init__(self,display):
        Frame.__init__(self,display)
        l = Label(self,text="frame2")
        l.pack()   

class test(Tk):

    def __init__(self):
        Tk.__init__(self)
        f = frame(self)
        f.grid(row=0)
        f2 = frame2(self)
        f2.grid(row=0)
        f.tkraise()

t = test()
t.mainloop()

如果两个框架的布局相同,但是如果我在第二个框架中添加另一个标签,则该标签在背景中仍然可见。有没有一种方法可以切换框架,以便仅显示凸起框架中的元素?

1 个答案:

答案 0 :(得分:0)

根据要求,这是我用来解决问题的方法:

From mathcomp
Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice fintype.
From mathcomp
Require Import tuple finfun bigop finset.

Variable ft : finType.

Structure dbranch := {branch :> seq ft ; buniq : uniq branch}.

Canonical dbranch_subType := Eval hnf in [subType for branch].
Canonical dbranch_eqType := Eval hnf in EqType _ [eqMixin of dbranch by <:].
Canonical dbranch_choiceType := Eval hnf in ChoiceType _ [choiceMixin of dbranch by <:].
Canonical dbranch_countType := Eval hnf in CountType _ [countMixin of dbranch by <:].
Canonical dbranch_subCountType := Eval hnf in [subCountType of dbranch].


Lemma dbranchFin : Finite.mixin_of [eqType of dbranch].
Admitted. (* :-( *)

Canonical dbranch_finType := Eval hnf in FinType _ dbranchFin.