#!/usr/bin/perl -w # Strict use strict; use warnings; # Libraries use Tk; # Main program create_gui(); # Subroutines sub create_gui { my $mw = new MainWindow(-title => 'Type "Escape" to exit...'); $mw->bind('' => sub { $mw->destroy() }); my $frame = $mw->Frame(-background => 'blue'); $frame->pack(-expand => 0, -fill => 'both'); # Note: 288 = 256 + 16 + 16 canvas($frame, 'hotpink', 'left', 16, 256 + 16 + 16); canvas($frame, 'gold', 'right', 16, 256 + 16 + 16); canvas($frame, 'maroon', 'top', 256, 16); canvas($frame, 'white', 'top', 256, 256); canvas($frame, 'purple', 'bottom', 256, 16); MainLoop; } sub canvas { my ($w, $background, $side, $width, $height) = @_; my $canvas = $w->Canvas(-background => $background); $canvas->configure(-width => $width); $canvas->configure(-height => $height); $canvas->pack(-expand => 1, -fill => 'both', -side => $side); return $canvas; } # # Key: H = Hotpink, M = Maroon, P = Purple, G = Gold, . = White # # The GUI I'm actually getting: The GUI I'd *LIKE* to get: # # +------------------------------+ +------------------------------+ # |Tk Type "Escape" to exit..." | |Tk Type "Escape" to exit..." | # +------------------------------+ +------------------------------+ # |H MMMMMMMMMMMMMMMMMMMMMMMM G| |HMMMMMMMMMMMMMMMMMMMMMMMMMMMMG| # |H G| |H............................G| # |H ........................ G| |H............................G| # |H ........................ G| |H............................G| # |H ........................ G| |H............................G| # |H ........................ G| |H............................G| # |H ........................ G| |H............................G| # |H ........................ G| |H............................G| # |H ........................ G| |H............................G| # |H ........................ G| |H............................G| # |H G| |H............................G| # |H PPPPPPPPPPPPPPPPPPPPPPPP G| |HPPPPPPPPPPPPPPPPPPPPPPPPPPPPG| # +------------------------------+ +------------------------------+ #