|Welcome to the Monastery|
Using Tk 8 menubar in its own windowby chrstphrchvz (Scribe)
|on May 23, 2018 at 11:28 UTC||Need Help??|
chrstphrchvz has asked for the wisdom of the Perl Monks concerning the following question:
Recently I've been trying to get a Perl/Tk program (HSW12, an IDE for programming microcontrollers) working with Tcl::pTk::TkHijack. One reason for doing so is letting the program be run on macOS using the native aqua UI instead of XQuartz. (Here's the full story on GitHub.)
One step I've taken is adapting the menubar to use the Tk 8 menu (cf. Mastering Perl/Tk - "12.2 Menubars and Pulldown Menus") rather than by packing Menubuttons. That way the native menubar at the top of the Mac's screen gets used instead of a menu in a window. However, the layout of the program has been such that the menubar is in its own window. When using the Tk 8 menu on non-Mac aqua, there is now a small amount of extra space (about 30 pixels vertically); and because there are no other widgets in the window, there doesn't appear to be anything to e.g. pack and remove the extra space. (See the bottom of this GitHub comment for a screenshot.)
Any ideas for how to remove this empty space/a way to force "pack" without widgets?
Some things I've already tried: I haven't found a suitable dummy widget that will shrink beyond some minimum size ≫0 (again, roughly 30 pixels). I thought I might set the toplevel's maxheight to the height of the menu, but I haven't found where that can be retrieved (the width and height of the menu is always 1x1 according to $menu->geometry). I'd rather not hardcode a height because the menu's height varies by platform and user theming/customizations.
Of course, one workaround would be to only use the Tk 8 menubar if running on Mac aqua (hiding the now-empty window using withdraw), and use the packed Menubuttons otherwise. One day I might use a module like Tk::IDElayout (compare to dock windows/panels in newer UI toolkits) which can let everything reside in a single toplevel window by default.