Dear Monks,
What am I doing wrong here ...
What I am trying to do:
I am trying to popup a dialog box
that has Notebook tabs in it.
Here's the error I am getting
$ ./blah.pl
Tk::Error: Failed to AUTOLOAD 'Tk::Frame::add' at ./blah.pl line 34
[\&main::callback,\{},View orders]
(menu invoke)
Here's my messed up code:
#!/usr/bin/perl -w
use strict;
use Tk;
use Tk qw(exit);
use TK::Menubar;
use Tk::DialogBox;
use Tk::Notebook;
use Tk::RoText;
my $top = MainWindow->new();
my $mb = $top->Menubar;
my $m1 = $mb->Menubutton ( -text => 'File' );
$m1->command(
-label => 'Blah 1',
-command => [sub { print "Blah 1\n"; }] );
my $m2 = $mb->Menubutton ( -text => 'Orders' );
$m2->command(
-label => 'View Orders',
-command => [\&callback, \$top, "View orders"] );
my $m3 = $mb->Menubutton ( -text => 'Customers' );
$m3->command(
-label => 'View Customers',
-command => [\&callback, \$top, "View Customers"] );
my $ro = $top->ROText()->pack( -anchor => 'n', -expand => 'both');
MainLoop();
sub callback {
my $t = shift || $top;
my $title = shift || "Unknown";
my $FILE1 = "whatever";
my $FILE2 = "something";
my $dd = $$t->DialogBox( -title => $title ); #->Frame();
my $d = $dd->Frame()->pack();
my $n = $d->NoteBook()->pack( -expand => 0, -fill => 'x' ); #,
+ -in => $$t);
my $p = $n->add( 'page1', -label => $title );
my $e1 = $p->add( 'Entry',
-width => 60,
-textvariable => \$FILE1 )->pack();
my $b1 = $p->add( 'Button',
-width => 10,
-text => 'File 1',
-command => [sub { print "$FILE1\n"; }]);
my $b2 = $p->add( 'Button',
-width => 10,
-text => 'Details',
-command => [\&callback, \$d, "Details"] );
$e1->pack();
$b1->pack();
$b2->pack();
$d->Show();
}
Is it just not possible to do this?
I am sure there is a way ... please help!
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.