show() problem!! 
Author Message
 show() problem!!

Hi,

I have tried to pass references, set up within package
subroutine 'Populate', to subroutine Show, but these
references were not recognized by Show so that I could not
perform a 'get' method on them:

has anyone a glue why this doesn't work???

/michael

please have a look as the package and the script file below!

sub Populate {
 ......

 my  $dir_entry = $top_right -> Entry();

.....

Quote:
}

sub show {
....


 $dir_name  = $dir_entry -> get;                     ?????
.....

Quote:
}

=========================================================================

package Tk::FileStore;

use Carp;
use strict qw(vars);

Tk::Widget->Construct('FileStore');

sub Populate
{


    $cw->InheritThis($args);

    my ($but,$pad1,$pad2);

    # Create the Toplevel window and divide it into top and bottom parts.

    $cw->{'selected_button'} = '';

    ($pad1, $pad2) =
        ([-padx => '3m', -pady => '3m'], [-padx => '3m', -pady => '2m']);

    $cw->withdraw;
    $cw->iconname('FileStore');
    $cw->protocol('WM_DELETE_WINDOW' => sub {});
    $cw->transient($cw->toplevel);

    my $top = $cw->Frame(Name => 'top',-relief => 'raised', -borderwidth => 1);

    my $bot = $cw->Frame(Name => 'bot',-relief => 'raised', -borderwidth => 1);


    # Fill the top part with the directory/filename label and the related entries


    my $top_left  = $top->Frame;
    my $top_right = $top->Frame;

    my  $dir_entry = $top_right -> Entry();
   $dir_entry -> pack;
   $dir_entry -> configure (-relief => 'groove');
   my $dir = $ENV{PWD}.'/';
   $dir_entry->insert(0,$dir);
   my $dir_label = $top_left -> Label(-text=>'Directory')->pack;

   my $file_entry = $top_right -> Entry();
   $file_entry -> pack;
   print "$file_entry\n";
   $file_entry -> configure (-relief => 'groove');
   my $default = 'insplan.txt';
   $file_entry->insert(0,$default);
   my $file_label = $top_left -> Label(-text=>'Filename')->pack;

   $top_left->pack(-side=>'left');
   $top_right->pack(-side=>'left');


   my $default_button = 0;

   # Create a row of buttons at the bottom of the dialog.

    my($w_default_button, $bl) = (undef, '');

        $but = $bot->Button(
            -text => $bl,
            -command => [
                sub {
                    $_[0]->{'selected_button'} = $_[1];
                }, $cw, $bl,
            ]
        );
        if ($bl eq $default_button) {
            $w_default_button = $bot->Frame(
                -relief      => 'sunken',
                -borderwidth => 1
            );
            $but->raise($w_default_button);

            $but->pack(-in => $w_default_button, -padx => '2m',
                         -pady => '2m');
            $cw->bind(
                '<Return>' => [
                    sub {
                        $_[1]->flash;
                        $_[2]->{'selected_button'} = $_[3];
                    }, $but, $cw, $bl,
                ]
            );
        } else {

        }
    } # forend all buttons

   $cw->{'default_button'} = $w_default_button;

Quote:
} # end Dialog constructor

sub show {

    # Dialog object public method - display the dialog.


     croak "Dialog:  `show' method requires at least 1 argument"

    my $old_focus = $cw->currentfocus;

    # Update all geometry information, center the dialog in the display
    # and deiconify it

    $cw->Popup();

    # set a grab and claim the focus.

    if (defined $grab_type && length $grab_type) {
        $cw->grab($grab_type);
    } else {
        $cw->grab;
    }
    $cw->tkwait('visibility', $cw);
    if (defined $cw->{'default_button'})
     {
      $cw->{'default_button'}->focus;
     }
    else
     {
      $cw->focus;
     }

    # Wait for the user to respond, restore the focus and grab, withdraw
    # the dialog and return the label of the selected button.

   my ($file_name,$dir_name);

    $cw->tkwait('variable' => \$cw->{'selected_button'});

   if ($cw->{'selected_button'} =~ /Accept/) {
       $dir_name  = $dir_entry -> get;
       $file_name = file_entry -> get;
    }
    $cw->grab('release');
    eval { $old_focus->focus } if defined $old_focus;
    $cw->withdraw;

    return ($dir_name,$file_name);

Quote:
} # end FileStore show method

1;

the perl script for testing:
#!/usr/bin/perl -w

use Tk;

require "<your path to package>FileStore.pm";

$main = MainWindow->new;
$main->configure(-title=>'FileStore Test');

$cw = $main->FileStore;

($dir,$name)=$cw->show;

print "Directory: $dir\n
       Filename : $name\n";

MainLoop;



Fri, 16 Apr 1999 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. File showing problem

2. Problems with MSIE in combination with MAC not showing Perl generated HTML

3. Perl Test Problem - show-shebang

4. Parse::RecDescent problem, $::RD_TRACE showing something very odd.

5. LabEntry problem - label not showing in 5.5.3

6. Problem to show a progress bar working

7. Perl script: given database query, show html result table

8. compiler warnings dont show up

9. Perl Gtk Tool Tips (show on some widgets, not others)

10. Show a sorted directory on a network share

11. request: to show next event from flat db

12. Perl 4.036 regression test shows bug in SunOS 4.1.1 tmpfs

 

 
Powered by phpBB® Forum Software