#!/usr/bin/perl package TkApp; use base qw(Class::Accessor); use strict; use warnings; use FileHandle; use Data::Dumper qw/Dumper/; use Date::Format; use Tk; use Tk::LabEntry; use Tk::DirTree; use Tk::HList; __PACKAGE__->follow_best_practice(); __PACKAGE__->mk_accessors(qw(mw graph)); our $VERSION = 0.1; =head1 NAME TkApp - experimental layout =head1 SYNOPSIS use strict; use warnings; my $app = TkApp->new(); $app->run(); =head1 DESCRIPTION - menu - entry box - two areas with equal size =head2 EXPORT None by default. =head1 METHODS =head2 new() Ctor. Calls _build_gui. =cut sub new { my $class = shift; my $self = bless({}, $class); my $mw = Tk::MainWindow->new(); $self->set_mw($mw); $self->_build_gui(); return $self; } # /new =head2 _build_gui() Build GUI. Set up widgets etc. Positioning is done here, too. Private method. Don't call it directly, as this will be done by new(). =cut sub _build_gui { my $self = shift; my $mw = $self->get_mw(); my %gui = (); # -- menu my $menuitems = [ [Cascade => "~File", -menuitems => [ [Button => "Some ~Method", -command => sub{ return $self->some_method(); }], [Separator => ""], [Button => "~Exit", -command => sub{ exit(0); }], ], ], ]; my $menu = $mw->Menu(-menuitems => $menuitems); $mw->configure(-menu => $menu); # define & pack your widgets here $gui{f_selectors} = $mw->Frame(-bg => 'green')->pack(-fill => 'x'); $gui{f_selectors}->LabEntry( -label=>"Abaqus Materialverzeichnis", -labelPack=>[-side=>'right'], -width=>80, -text => 'TODO: initial value', )->pack(-padx => 20, -pady => 5); $gui{f_row2} = $mw->Frame( -bg => 'yellow' )->pack(-fill => 'both', -expand => 1,); $gui{f_left} = $gui{f_row2}->Frame( -bg => 'red', )->pack( -side => 'left', -fill => 'both', -expand => 1, ); $gui{f_left}->Label(-text => 'test')->pack(); $gui{f_right} = $gui{f_row2}->Frame( -bg => 'blue', )->pack( -side => 'right', -fill => 'both', -expand => 1, ); } # /_build_gui =head2 run() This actually starts the application, including the gui event loop. =cut sub run { my $self = shift; my $mw = $self->get_mw(); $mw->MainLoop(); } # /run =head1 SEE ALSO Inspired by a thread at L. =head1 AUTHOR todo =head1 COPYRIGHT AND LICENSE Copyright (C) 2010 by todo This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available. =cut 1; use strict; use warnings; my $app = TkApp->new(); $app->run();