[Tkinter-discuss] ttk.Notebook: autohide

Vasilis Vlachoudis Vasilis.Vlachoudis at cern.ch
Sun Jun 2 10:22:56 EDT 2019

Many thanks

The first solution works ok for me without any flickering

I think you are right it is a bug in tk, probably they forget
to invalidate the window


From: Tkinter-discuss [tkinter-discuss-bounces+vasilis.vlachoudis=cern.ch at python.org] on behalf of Michael Lange [klappnase at web.de]
Sent: Friday, May 31, 2019 00:33
To: tkinter-discuss at python.org
Subject: Re: [Tkinter-discuss] ttk.Notebook: autohide


On Thu, 30 May 2019 19:49:33 +0000
Vasilis Vlachoudis <Vasilis.Vlachoudis at cern.ch> wrote:

> Many thanks Michael.
> The recipe works the tab bar disappears (and reappears), but the space
> of the tabs is not reclaimed. the child-window is not resized to get
> the extra space. If I resize the toplevel window with the mouse then it
> works.

oh, I see. This "works" also vice versa here, the tab only reappears
after resizing the window with the mouse. Too bad, looks like a bug to me.

> Is there a way to force the layout manager to recalculate all widgets?

I am not sure how to do this, except with an ugly hack like:

def hidetabs(ev):
    s.layout('TNotebook.Tab', [])
    nb.pack(fill='both', expand=1)

But that looks rather stupid and besides causes an annoying "flickering"
effect. The flickering seems to be a bit better with a "minimally
invasive" re-packing, as in

def hidetabs(ev):
    s.layout('TNotebook.Tab', [])
    info = nb.pack_info()
    px = info['padx']
    del info['padx']
    nb.pack(padx=px + 1, **info)
    nb.pack(padx=px, **info)

but this looks somehow even more stupid.
But maybe I just miss something obvious?

Best regards


.-.. .. ...- .   .-.. --- -. --.   .- -. -..   .--. .-. --- ... .--. . .-.

"Can you imagine how life could be improved if we could do away with
jealousy, greed, hate ..."

"It can also be improved by eliminating love, tenderness, sentiment --
the other side of the coin"
                -- Dr. Roger Corby and Kirk, "What are Little Girls Made
                   Of?", stardate 2712.4
Tkinter-discuss mailing list
Tkinter-discuss at python.org

More information about the Tkinter-discuss mailing list