Re: perl Tk question

2005-06-01 Thread Zeray Abraha
Hi,
You are deleting whatever is in $text0 till the énd'.
Comment that out and you will see all the values of $i.

...

sub prg{
for (my $i=0;$i<20;$i++){
   #   $text0->delete('0.0','end');# commented out
   $text0->insert('end',"$i\n");
   #   sleep 1;
}
 }

Bye,
Zeray



|-+->
| | |
| | |
| | |
| | |
| | |
| |[EMAIL PROTECTED]  |
| | |
| |Sent by: |
| |[EMAIL PROTECTED]|
| |.com |
| | |
| |2005-06-01 10:06 AM  |
| |Please respond to synoptic   |
|-+->
  
>--|
  | 
 |
  |   To:   perl-win32-users@listserv.ActiveState.com   
         |
  |   cc:   (bcc: Zeray Abraha/WLR/SC/PHILIPS)  
 |
  |   Subject:perl Tk question  
 |
  | 
 |
  |   Classification:   
 |
  | 
 |
  | 
 |
  
>--|




Hi All!
In the following snippet:

use strict;
use Tk;
require Tk::LabFrame;
my $top = new MainWindow;
my $bar=$top->LabFrame(-label => 'buttons bar');
$bar->pack;
my $exi=$bar->Button(-command=>\&exi,-text=>'exit');
$exi->pack(-side=>'left');
my $prg=$bar->Button(-command=>\&prg,-text=>'prg');
$prg->pack(-side=>'left');
my $fr=$top->LabFrame();
$fr->configure(-height=>'5',-width=>"30");
$fr->pack(-fill=>'none');
my $text0=$fr->Text();
$text0->configure(-height=>'10',-width=>"20");
$text0->pack(-side=>'top',-fill=>'none');
MainLoop;
sub exi{
 $top->destroy;
 }
sub prg{
 for (my $i=0;$i<20;$i++){
 $text0->delete('0.0','end');
 $text0->insert('end',"$i\n");
 sleep 1;
 }
 }

When executing this snippet
I see in text0 only the last $i /in for cycle/
What I  must add to prg code
in order to see all cosequtive values of $i ?
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Easy way of using module Env, platform independent?

2004-11-08 Thread zeray . abraha




Thanks Roger.
I will use the hint you gave me and will further explore/modify it to fit
my requirement.

Regards,
Zeray




  

  
To:   
"'[EMAIL PROTECTED]'"   
 
<[EMAIL PROTECTED]>  
        cc:   
(bcc: Zeray Abraha/WLR/SC/PHILIPS)  

Subject:Re: Easy way of using module Env, platform independent?   
   Roger Keane <[EMAIL PROTECTED]>  


Classification:   
   Sent by: 
  
   [EMAIL PROTECTED]
  
   .com 
  

  
   2004-11-05 16:51 
  

  

  




[EMAIL PROTECTED] wrote:

>
>
>
> # Hi,
> # Question. Easy way of using module Env, platform independent.
> # Want to do the following: (example)
> # 1. get the PATH environment variable
> # 2. change it to add an additional search path
> # 3. put back the modified PATH
> # 4. execute a program/script using the system command.
> # Example below works but I don't like it. There must be an easy way,
> similar to setenv("")
> # that also takes care of the platform independence.
> # Your help is appreciated.
>
> use strict;
> my @PATH=();
> use Env; # Env qw(PATH);
> my $mswin=0;
> my $home="";
> $mswin=1 if ($^O =~ /MSWin/);
>
> @PATH=split(/;/,$ENV{'PATH'}) if $mswin; # for windows
> @PATH=split(/:/,$ENV{'PATH'}) if !$mswin;# for unix
>
> $home=$ENV{'HOMEPATH'} if $mswin;# for windows
> $home=$ENV{'HOME'} . '/' if !$mswin; # for unix
>
> print "home=$home\n";
>
> my $toolpath="${home}tmp/bin";   # in this path is my
> executable
> $toolpath =~ s/\//\\/g if $mswin;# adjust for windows
> print "toolpath=$toolpath\n";
>
> push(@PATH, $toolpath);  # add to the PATH
> environment variable
> $ENV{'PATH'}=join(($mswin)? ';':':', @PATH); # set the PATH env.
> thus
> print "PATH=",$ENV{'PATH'}, "\n";# see if toolpath is
> added
>
> # execute your program now using system command.
> # For this example, for unix, 'chmod +x ztest.bat'; ztest.bat prints
' message>'
> system("ztest.bat");
> print "Unknown command\n" if $?;
>
> # Thanks
> # zeray

If you version of Perl is recent enough (5.6.0 or better, I think) the
array support for the path-like variables is already built-in to the Env
module, and is platform independent (uses the $Config{path_sep} variable).
You still need to be wary of path directory separators.  There are platform
independent modules for constructing the pathnames (see File::Spec), but
here's a qnd approach that works for windoze XP and *nix:


#!perl -w
use strict;
require v5.6.0;
use Env qw( @PATH $HOME $HOMEDRIVE $HOMEPATH );
sub isWindoze() { return $^O =~ /Win32/; }
sub getHome() { return isWindoze() ? $HOMEDRIVE . $HOMEPATH : $HOME; }
sub add_paths(@)
{
  

Easy way of using module Env, platform independent?

2004-11-05 Thread zeray . abraha




# Hi,
# Question. Easy way of using module Env, platform independent.
# Want to do the following: (example)
# 1. get the PATH environment variable
# 2. change it to add an additional search path
# 3. put back the modified PATH
# 4. execute a program/script using the system command.
# Example below works but I don't like it. There must be an easy way,
similar to setenv("")
# that also takes care of the platform independence.
# Your help is appreciated.

use strict;
my @PATH=();
use Env; # Env qw(PATH);
my $mswin=0;
my $home="";
$mswin=1 if ($^O =~ /MSWin/);

@PATH=split(/;/,$ENV{'PATH'}) if $mswin; # for windows
@PATH=split(/:/,$ENV{'PATH'}) if !$mswin;# for unix

$home=$ENV{'HOMEPATH'} if $mswin;# for windows
$home=$ENV{'HOME'} . '/' if !$mswin; # for unix

print "home=$home\n";

my $toolpath="${home}tmp/bin";   # in this path is my
executable
$toolpath =~ s/\//\\/g if $mswin;# adjust for windows
print "toolpath=$toolpath\n";

push(@PATH, $toolpath);  # add to the PATH
environment variable
$ENV{'PATH'}=join(($mswin)? ';':':', @PATH); # set the PATH env.
thus
print "PATH=",$ENV{'PATH'}, "\n";# see if toolpath is
added

# execute your program now using system command.
# For this example, for unix, 'chmod +x ztest.bat'; ztest.bat prints ''
system("ztest.bat");
print "Unknown command\n" if $?;

# Thanks
# zeray


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs