[Tkinter-discuss] ttk.Notebook: autohide

Michael Lange klappnase at web.de
Thu May 30 18:33:22 EDT 2019


Hi,

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(expand=0)
    nb.update_idletasks()
    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.update_idletasks()
    nb.pack(padx=px, **info)

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

Best regards

Michael

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

"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


More information about the Tkinter-discuss mailing list