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

To Monks,

I'm trying to develop a Perl GUI which utilises TK::DynaTabFrame however I'm falling over at the first hurdle as I can't even get a simple example GUI to work. The GUI should show two tabs 'Tab 1' and 'Tab 2' each will contain a button.

Any help would be kindly accepted.
Butch.
#! /usr/bin/perl use strict; use warnings; use Tk; use Tk::DynaTabFrame; my $mw = MainWindow->new(); my $TabbedFrame = $mw->DynaTabFrame ( ); my $frame = $TabbedFrame->add ( -caption => 'Tab 1', -tabcolor => 'yellow', -hidden => 0 ); my $button = $frame->Button( -text => 'Button 1 on Tab 1' ); my $frame2 = $TabbedFrame->add ( -caption => 'Tab 2', -tabcolor => 'red', -hidden => 0 ); my $button2 = $frame->Button( -text => 'Button 1 on Tab 2' ); MainLoop();

2006-03-14 Retitled by planetscape, as per Monastery guidelines
Original title: 'TK GUI problem - can't make tabs visible with DynaTabFrame'

Replies are listed 'Best First'.
Re: Examples for Tk::DynaTabFrame?
by zentara (Cardinal) on Mar 13, 2006 at 17:36 UTC
    You forgot to pack your widgets. The widgets in Tk can be made, but they won't be seen until you pack, place or grid them onto the screen. Additionally, DynaTabFrame dosn't seem to expand a window, so you need to set a default size for the $mw.
    #! /usr/bin/perl use strict; use warnings; use Tk; use Tk::DynaTabFrame; my $mw = MainWindow->new(); $mw->geometry('200x200'); my $TabbedFrame = $mw->DynaTabFrame() ->pack(-side => 'top', -expand => 1, -fill => 'both'); my $frame = $TabbedFrame->add( -caption => 'Tab 1', -tabcolor => 'yellow', -hidden => 0 ); my $button = $frame->Button( -text => 'Button 1 on Tab 1' )->pack(); my $frame2 = $TabbedFrame->add( -caption => 'Tab 2', -tabcolor => 'red', -hidden => 0 ); my $button2 = $frame->Button( -text => 'Button 1 on Tab 2' )->pack(); MainLoop();

    I'm not really a human, but I play one on earth. flash japh
      Thanks Zentara - that's exactly the help I needed.
      I'll go away and read up on pack \ grid.