Prevent [Ruby/]Tk window resizing

Software

Screenshot showing a tk window that can't be resized

I had some trouble finding how to prevent Tk windows from being resized by users at runtime, so now that I've found out how I'm putting it here and passing it off as a legitimate post. Clever, right? :). Entirely pointless introductory paragraphs aside, simply set the resizable attribute of the TkRoot to (0, 0). Looks like a guy with a crooked nose.

For example, if you're a Rubyist using a beautiful block to create your new TkRoot window:

rootMain = TkRoot.new |main| do
  [..]
  resizable 0, 0
end

Or if you're doing it the more traditional way with hash parameters:

rootMain = tkRoot.new{ 'resizable' => '0, 0', [..] }

And because I used to be a Perl Guy and still use it for some stuff:

$rootMain->resizable(0, 0);

The next thing I need to find out is how to allow only horizontal resizing while vertical resizing is locked, and vica versa. Any ideas?

Author bio and support

Me!

Ruben Schade is a technical writer and IaaS engineer in Sydney, Australia who refers to himself in the third person in bios. Wait, not BIOS… my brain should be EFI by now.

The site is powered by Hugo, FreeBSD, and OpenZFS on OrionVM, everyone’s favourite cloud infrastructure provider.

If you found this post helpful or entertaining, you can shout me a coffee or buy some silly merch. Thanks!