Re: [Tkinter-discuss] ttk.Notebook: autohide
Hi, On Sun, 2 Jun 2019 14:22:56 + Vasilis Vlachoudis wrote: > Many thanks > > The first solution works ok for me without any flickering probably it depends on the speed of the machine. With an old and slow laptop of mine the flickering effect appears to be a bit worse than on my desktop machine. Changing only the padx by one pixel seems to cause only a slightly "trembling" effect that is hardly noticable at all, so I guess the second workaround might be a bit better. (Maybe calling those workarounds "stupid" the other day was a bit harsh, if there's actually nothing better the second version might be not so bad) > > I think you are right it is a bug in tk, probably they forget > to invalidate the window Still I am not sure if I didn't miss something here. I think one bad thing about ttk is that the more advanced operations on styles and themes aren't really documented very well, so I always find it hard to find out how to do things properly, I always end up with some try-and-error solution. Best regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. Death. Destruction. Disease. Horror. That's what war is all about. That's what makes it a thing to be avoided. -- Kirk, "A Taste of Armageddon", stardate 3193.0 ___ Tkinter-discuss mailing list Tkinter-discuss@python.org https://mail.python.org/mailman/listinfo/tkinter-discuss
Re: [Tkinter-discuss] ttk.Notebook: autohide
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 Vasilis From: Tkinter-discuss [tkinter-discuss-bounces+vasilis.vlachoudis=cern...@python.org] on behalf of Michael Lange [klappn...@web.de] Sent: Friday, May 31, 2019 00:33 To: tkinter-discuss@python.org Subject: Re: [Tkinter-discuss] ttk.Notebook: autohide Hi, On Thu, 30 May 2019 19:49:33 + Vasilis Vlachoudis 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 ___ Tkinter-discuss mailing list Tkinter-discuss@python.org https://mail.python.org/mailman/listinfo/tkinter-discuss ___ Tkinter-discuss mailing list Tkinter-discuss@python.org https://mail.python.org/mailman/listinfo/tkinter-discuss
Re: [Tkinter-discuss] ttk.Notebook: autohide
Hi, On Thu, 30 May 2019 19:49:33 + Vasilis Vlachoudis 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 ___ Tkinter-discuss mailing list Tkinter-discuss@python.org https://mail.python.org/mailman/listinfo/tkinter-discuss
Re: [Tkinter-discuss] ttk.Notebook: autohide
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...@python.org] on behalf of Michael Lange [klappn...@web.de] Sent: Wednesday, May 29, 2019 23:56 To: tkinter-discuss@python.org Subject: Re: [Tkinter-discuss] ttk.Notebook: autohide Hi, On Wed, 29 May 2019 13:01:16 + Vasilis Vlachoudis 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@python.org https://mail.python.org/mailman/listinfo/tkinter-discuss ___ Tkinter-discuss mailing list Tkinter-discuss@python.org https://mail.python.org/mailman/listinfo/tkinter-discuss
Re: [Tkinter-discuss] ttk.Notebook: autohide
Hi, On Wed, 29 May 2019 13:01:16 + Vasilis Vlachoudis 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@python.org https://mail.python.org/mailman/listinfo/tkinter-discuss