Sequencially draw windows 
Author Message
 Sequencially draw windows

 > Hi,
 >
 > I need to paint a new window based on the outcome of the previous one.
 > That is, Window A has one Entry widget and a "OK" button and a "Cancel"
 > button. When the "OK" button is pressed, Window B must be drawn.
 > Example
 [...]

I'm not sure if I know what you want.  You use 'Window X' as if you
mean Toplevel X.  But your example would add the widgets to the
widgets already in Mainwindow.   Nevertheless here a short example how
to do it with several (toplevel) window.  

use Tk;
use strict;


sub FillWindow {

        $t->Label(-text => "$v value")->pack;
        $t->Button(-text => 'Dismiss', -command=>sub{$t->withdraw})->pack;

Quote:
}

my $mw = MainWindow->new();


        my $t = $mw->Toplevel(-title => $_);
        my $b = $mw->Button(-text=>$_, -command=>sub{$t->deiconify})->pack;
        $t->withdraw;
        no strict 'refs';
        &{"FillWindow" . $_}($t, $_);  # or for you &{"FillWindow" . $_}($t);

Quote:
}

$mw->Button(-text => 'Exit', -command=>sub{$mw->destroy})->pack;

MainLoop;
__END__

If you really want to add/remove them to the same toplevel you should
look at packForget also remove later.  But somehow I don't like
this way of solving the problem.

Achim

==========================================================================
This message was posted through the Stanford campus mailing list
server.  If you wish to unsubscribe from this mailing list, send the

--




Mon, 06 Dec 1999 03:00:00 GMT  
 Sequencially draw windows

Quote:
Tom Van Graan writes:



 > Subject: Sequencially  draw windows
 > Date: Thu, 19 Jun 1997 17:58:59 +0200
 >
 > Hi,
 >
 > I need to paint a new window based on the outcome of the previous one.
 > That is, Window A has one Entry widget and a "OK" button and a "Cancel"
 > button. When the "OK" button is pressed, Window B must be drawn.
 > Example
 >

Possibly Better example:

use strict;
use Tk;

my($top, $b, $txt, $windowB);

$top = MainWindow->new;

$top->withdraw;
$top->title('Top');

$top->Entry(-textvariable => \$txt)->pack;

$top->Button(-text => 'OK',
             -command => sub {
                 $windowB->deiconify;
                 $b->configure(-text =>
                               "Push and Push, I'll still say \"$txt\"");

                 $windowB->update;
                 $top->withdraw;
             })->pack;

$top->Button(-text => 'Cancel',
             -command => sub {
                 $top->destroy;
             })->pack;

$windowB = $top->Toplevel(-title => 'Window B');
$windowB->withdraw;
$b = $windowB->Button(-text => "OK",
                 -command => sub {
                     $windowB->withdraw;
                     $top->deiconify;
                 })->pack;

$b = $windowB->Button()->pack;

$top->deiconify;

MainLoop;

 >
 > I dont' want to use waitWindow because no other backgound window in the
 > application is accessable. When WindowA is painted, I should be able to
 > access any other window in the application and NOT sit and wait for
 > WindowA to destory. The user should be able to lookup values in other
 > windows whilst being in WindowA.
 >
 > My aim is to build a file(called Widgets.ph) that contains all the sub's
 > to draw predefined windows. The main program will include Widgets.ph and
 > then call the sub's as required.
 >
==========================================================================
This message was posted through the Stanford campus mailing list
server.  If you wish to unsubscribe from this mailing list, send the

--




Mon, 06 Dec 1999 03:00:00 GMT  
 Sequencially draw windows

Tom:

It looks like your still thinking a bit too procedurally for the callback
nature of perl/Tk (and just about any windowing environment).

You might try something like this..

$mw=new MainWindow;

&windowa($mw,\&windowb,\&windowc);

sub windowa {

  $mw->Button(-text => 'Ok',-command => $yes_sub)->pack;
  $mw->Button(-text => 'Cancel',-command => $no_sub)->pack;

Quote:
}

sub windowb {
  ...

Quote:
}

sub windowc {
  ...

Quote:
}

Note that you can also pass parameters to the windowb subroutine by passing a
reference to a list like [\&windowb,3,7]

Andrew

Quote:
> I need to paint a new window based on the outcome of the previous one.
> That is, Window A has one Entry widget and a "OK" button and a "Cancel"
> button. When the "OK" button is pressed, Window B must be drawn.
> Example

> use Tk;
> $Top=MainWindow->new();
> $Val=&WindowA($Top);
> if ($Val eq "Y") {
>   &WindowB($Top);
> }

> MainLoop;

> sub WindowA {

> $e1 = $mw->Entry()->pack();
> $b1 = $bw->Button()->pack()
> $b2 = $mw->Button()->pack();
> $b1->bind('<1>', sub {
>    $return ="Y"});
> $b2 ->bind('<1>',sub {
>   $return ="N"});
> # $mw->waitWindow; # NO!!???
> $return;
> }
> sub WindowB {

> $e1 = $mw->Entry()->pack();
> $b1 = $bw->Button()->pack()
> $b2 = $mw->Button()->pack();
> }

> I dont' want to use waitWindow because no other backgound window in the
> application is accessable. When WindowA is painted, I should be able to
> access any other window in the application and NOT sit and wait for
> WindowA to destory. The user should be able to lookup values in other
> windows whilst being in WindowA.

==========================================================================
This message was posted through the Stanford campus mailing list
server.  If you wish to unsubscribe from this mailing list, send the

--




Mon, 06 Dec 1999 03:00:00 GMT  
 Sequencially draw windows

Hi,

I need to paint a new window based on the outcome of the previous one.
That is, Window A has one Entry widget and a "OK" button and a "Cancel"
button. When the "OK" button is pressed, Window B must be drawn.
Example

use Tk;
$Top=MainWindow->new();
$Val=&WindowA($Top);
if ($Val eq "Y") {
  &WindowB($Top);

Quote:
}

MainLoop;

sub WindowA {

$e1 = $mw->Entry()->pack();
$b1 = $bw->Button()->pack()
$b2 = $mw->Button()->pack();
$b1->bind('<1>', sub {
   $return ="Y"});
$b2 ->bind('<1>',sub {
  $return ="N"});
# $mw->waitWindow; # NO!!???
$return;

Quote:
}

sub WindowB {

$e1 = $mw->Entry()->pack();
$b1 = $bw->Button()->pack()
$b2 = $mw->Button()->pack();

Quote:
}

I dont' want to use waitWindow because no other backgound window in the
application is accessable. When WindowA is painted, I should be able to
access any other window in the application and NOT sit and wait for
WindowA to destory. The user should be able to lookup values in other
windows whilst being in WindowA.

My aim is to build a file(called Widgets.ph) that contains all the sub's
to draw predefined windows. The main program will include Widgets.ph and
then call the sub's as required.

Thanx

Jan van Zyl

Tom van Graan
IT Consultant: CBS Development
Sancardia
(012) 323 2637

==========================================================================
This message was posted through the Stanford campus mailing list
server.  If you wish to unsubscribe from this mailing list, send the

--




Mon, 06 Dec 1999 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. delayed drawing of window contents

2. Perl Library for Drawing Mac PICT Files

3. drawing on the screen (Win32)

4. How to draw thin lines with Image::Magick?

5. ANNONCE: True color drawing extension for Perl

6. Module for drawing and image processing

7. Regexp: Drawing syntax diagram / graph

8. Drawing a Gantt chart using Perl on Win32!

9. Drawing graphs in Perl?

10. Drawing names for Christmas with perl

11. Curses.pm support for line draw chars and/or ANSI color

12. Drawing a blank

 

 
Powered by phpBB® Forum Software