[Tkinter-discuss] ttk.Notebook: autohide

Vasilis Vlachoudis Vasilis.Vlachoudis at cern.ch
Thu May 30 15:49:33 EDT 2019


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.

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

Best regards
Vasilis




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

Hi,

On Wed, 29 May 2019 13:01:16 +0000
Vasilis Vlachoudis <Vasilis.Vlachoudis at cern.ch> wrote:

> Hi all
>
> I am using the ttk.Notebook for an editor like application and I want
> to implement something like autohide functionality for the tabheadings
> when there is only one tab, and to reappear when there are more than
> one.
>
> Is there some function to set the height to 0 for the headings of
> "pack_forget" equivalent in the style?

it seems you can show or hide the tabs with something like:

s=ttk.Style()
# store default layout options
tablayout = s.layout('TNotebook.Tab')
# hide tabs
s.layout('TNotebook.Tab', [])
# show tabs again
s.layout('TNotebook.Tab',tablayout)

Idea borrowed from:
https://stackoverflow.com/questions/26923010/how-do-i-hide-the-entire-tab-bar-in-a-tkinter-ttk-notebook-widget

Best regards

Michael

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

There is an old custom among my people.  When a woman saves a man's
life, he is grateful.
                -- Nona, the Kanuto witch woman, "A Private Little War",
                   stardate 4211.8.
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss at python.org
https://mail.python.org/mailman/listinfo/tkinter-discuss


More information about the Tkinter-discuss mailing list