svad has asked for the wisdom of the Perl Monks concerning the following question:

Hello, wise perlmonks!
How can I get rid of those buttons in Toplevel window, such as minimize, maximize and close buttons?

Something like we can see in Tk::BrowseEntry implementation that does $c->overrideredirect(1) and $c->withdraw; seems too much to me, because title bar also disappears (and I can not move window after that).

Thanks in advance and best wishes,
Vadim.

  • Comment on How to get rid of system buttons on Tk::Toplevel

Replies are listed 'Best First'.
Re: How to get rid of system buttons on Tk::Toplevel
by graff (Chancellor) on May 27, 2002 at 00:19 UTC
    I'm speaking from limited experience, but my understanding is that the "minimize, maximize, close" buttons represent functions of the desktop window manager -- not the individual process that occupies a given window. Also, these functions are intrinsic to the title-bar, which is rendered (or not) by the window manager (potentially at the request of the process).

    So I think the answer is "no", you can't control the presence/absence of these buttons from within the Perl/Tk script. With some window managers (in X Windows), you can control which windows get title bars or don't (based on process or window names), and even dictate what control buttons are provided on title bars generally, but this isn't something that a Perl/Tk script can do for itself, by itself. (X window managers also provide a "border" on all windows, which can be used to move or resize windows instead of a title bar.)

    A Perl/Tk process can, of course, dictate its own geometry and placement to the window manager, meaning that it should be possible to control placement and size of the app window even when you create it without a title bar. But if the user needs to adjust this during runtime, it's better to leave that to the standard window-manager methods.

    The next step may be to focus on why you don't want the window to provide these buttons; "minimize" seems harmless (and I'd recommend keeping it in any case), while "maximize" can be annoyance when hit by mistake (but maybe $topwin->resizable(0,0) might help), and "close" could be nasty if you don't have an appropriate mechanism to handle that sort of event -- but this is what "OnDestroy(callback)" is for (not to mention the END block).

      Good point.
      Seems like there is documented way to do such tricks with Motif window manager using mwmDecoration (Mwm.pod describes this), and for common case resizable(0,0) seems like most one can do.

      Thank you for a useful tip.