in reply to WinRT, Metro, Windows 8

The following script is an basic attempt at simulating a Windows 8 (WinRT, Metro, etc...) application GUI.
The main features are fullscreen only, no chrome, and a top and bottom app bar that are displayed when the cursor (or finger on touch screens) is at the top/bottom of the screen, and hidden otherwise.

I have used text labels on the "app bars" for demonstration purposes, a real app would have buttons that do things in place of the text labels.

#!/usr/bin/perl use warnings; use strict; use Tk; #create a new MainWindow my $mw = MainWindow->new( -background => 'black' ); #fullscreen $mw->geometry($mw->screenwidth.'x'.$mw->screenheight); #remove window chrome $mw->overrideredirect(1); #create a Tk::Frame to act as the top app bar hotspot. my $top_appbar = $mw->Frame( -background => $mw->cget(-background), -h +eight => 10 )->pack( -side => 'top', -fill => 'x' ); $top_appbar->bind('<Any-Enter>' => sub { \&AppBar($top_appbar, 'show', + 'top'); } ); $top_appbar->bind('<Any-Leave>' => sub { \&AppBar($top_appbar, 'hide', + 'top'); } ); #create a Tk::Frame to act as the bottom app bar hotspot my $bottom_appbar = $mw->Frame( -background => $mw->cget(-background), + -height => 10 )->pack( -side => 'bottom', -fill => 'x' ); $bottom_appbar->bind('<Any-Enter>' => sub { \&AppBar($bottom_appbar, ' +show', 'bottom'); } ); $bottom_appbar->bind('<Any-Leave>' => sub { \&AppBar($bottom_appbar, ' +hide', 'bottom'); } ); #create a Tk::Frame to hold the application's content my $content = $mw->Frame( -background => $mw->cget(-background), -heig +ht => $mw->screenheight-20 )->pack( -fill => 'x' ); $content->Label( -text => 'This is where the application content is di +splayed (buttons, images, etc...)', -background => $mw->cget(-backgro +und), -foreground => 'gray' )->pack(); sub AppBar { my $self = shift; my $method = shift; my $name = shift; if ($method eq 'show'){ #change the appbar's height and color to make it visable and u +seable $self->configure( -background => 'gray' ); $self->configure( -height => 50) if $name eq 'top'; if ( $name eq 'top' ){ $top_appbar->{label1} = $top_appbar->Label( -text => 'The +navigation bar, or top app bar, is the recommended place to put navig +ation controls that let the user access other areas of the app (butto +ns).', -background => 'gray', -foreground => 'black' )->pack( -side = +> 'left' ); } elsif ( $name eq 'bottom' ){ $bottom_appbar->{label1} = $bottom_appbar->Label( -text => + 'The bottom app bar is the recommended place to put commands (button +s).', -background => 'gray', -foreground => 'black' )->pack( -side = +> 'left' ); $self->configure( -height => 50); $mw->configure( -height => $mw->screenheight-60 ); } } elsif ($method eq 'hide'){ #change the appbar's height and color to make it hidden and no +t useable $self->configure( -background => $mw->cget(-background) ); $self->configure( -height => 10) if $name eq 'top'; if ( $name eq 'top'){ $top_appbar->{label1}->packForget(); } elsif ( $name eq 'bottom' ){ $bottom_appbar->{label1}->packForget(); $self->configure( -height => 10 ); $mw->configure( -height => $mw->screenheight-20 ); } } $mw->update(); } $mw->MainLoop();