473,398 Members | 2,389 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

perl tk/command bound to an event

when i run my code it's occurred an error

my code...
Expand|Select|Wrap|Line Numbers
  1. sub starting {
  2.  
  3. $out1=`perl macswitch.pl`;
  4.  
  5. foreach ($out1){
  6. chomp;
  7. $tx->insert('end', "$_\n" );
  8. }
  9.  
  10. open (FILE, ">mac.txt")|| die "$!";
  11. print FILE "$out1";
  12. close FILE;
  13.  
  14. open (A, "<mac.txt") || die "$!";
  15. open (B, "<macs.txt") || die  "$!";
  16. local $/;
  17. my @res =();
  18. my @res1 =();
  19. my @res2 =();
  20.  
  21. my @a = split /\n/, <A>;
  22. my @b = split /\n/, <B>;
  23.  
  24. my %a = map { $_ => 1 } @a; # Make hash of B
  25. @res1 = grep { !defined $a{$_} } @b; # Everything in B not in A
  26. $tx2->insert('end', @res1 );
  27.  
  28.  
  29. my %b = map { $_ => 1 } @b; # Make hash of B
  30. @res2 = grep { !defined $b{$_} } @a; # Everything in A not in B
  31. $tx3->insert('end', @res2 );
  32.  
  33. close A;
  34. close B;
  35. }
  36.  
  37. Error is.......
  38.  
  39. Tk::Error: wrong # args: should be ".frame1.text1 insert index chars ?tagList chars tagList ...?" at C:/Perl/lib/Tk.pm line 252, <C> chunk 1.
  40.  Tk callback for .frame1.text1
  41.  Tk callback for .frame.button2
  42.  Tk::__ANON__ at C:/Perl/lib/Tk.pm line 252
  43.  Tk::Button::butUp at C:/Perl/lib/Tk/Button.pm line 111
  44.  <ButtonRelease-1>
  45.  (command bound to event)
  46.  
pls any help..........
Oct 16 '08 #1
2 3575
aurekha
34
I think ,the error lies in your perl-Tk coding while specifying arguements ,

Will you again post your tk code, so that i can able to fix the error..?
Oct 18 '08 #2
I think ,the error lies in your perl-Tk coding while specifying arguements ,

Will you again post your tk code, so that i can able to fix the error..?

my tk code.........

#!/usr/bin/perl -w


eval '(exit $?0)' && eval 'exec /usr/local/bin/perl $0 ${1+"$@"}'
&& eval 'exec /usr/local/bin/perl $0 $argv:q'
if 0;

use Tk;
use Tk ':variables';
use strict;
use warnings;
use Tk::Adjuster;
use File::Compare;
use Tk::Frame;
use Tk::TextUndo;
use Tk::Text;
use Tk::Scrollbar;
use Tk::Menu;
use Tk::Menubutton;
use Tk::DialogBox;
use Tk::Label;

use Net::SNMP qw(snmp_dispatcher oid_lex_sort);
use Tk::ItemStyle;
use List::Compare;

################################################## ######
# MAIN WINDOW
################################################## ######

my $mw = MainWindow->new;
$mw->geometry("600x500");
$mw->title("Network Device Monitoring tool");


################################################## #######
# WIDGETS
################################################## #######

#top level frame.....

my $frmTop = $mw->Frame(-bd => 3, -relief => 'ridge')
->pack(-side => 'top', -fill => 'x', -pady => 1);


$frmTop->Button(-text => "get data", -command =>\&pra,-background => '#BC8F8F')->pack(-ipadx => 10,-ipady => 4,-padx => 15,-pady => 15,-side =>"left",-expand
=>"no",-anchor =>"nw");

$frmTop->Button(-text => "new data", -command =>\&pra3,-background => '#BC8F8F')->pack(-ipadx => 10,-ipady => 4,-padx => 150 ,-pady => 15,-side =>"left",-expand
=>"no",-anchor =>"center");

$frmTop->Button(-text => "check", -command =>\&comparing,-background => '#BC8F8F')->pack(-ipadx => 10,-ipady => 4,-padx => 15,-pady => 15,-side =>"right",-expand
=>"no",-anchor =>"e");

#middle level frame......

my $frmMiddle = $mw->Frame(-bd => 3, -relief => 'ridge')
->pack(-side => 'top', -fill => 'x');

my $frmMiddle1 = $frmMiddle->Frame(-bd => 2)->pack(
-side => 'top', -fill => 'x');

$frmMiddle1->Label(-text=>"currently connected ")->pack(-padx => 15,-pady => 1,-side => 'left',-expand =>"no");
$frmMiddle1->Label(-text=>"newly connected")->pack(-padx => 78,-pady => 1,-side => 'left',-expand =>"no");
$frmMiddle1->Label(-text=>"currently not connected")->pack(-padx => 45,-pady => 1,-side => 'right',-expand =>"no");


my $scrollbar1 =$frmMiddle ->Scrollbar( );
my $scrollbar2 =$frmMiddle ->Scrollbar( );
my $scrollbar3 =$frmMiddle ->Scrollbar( );



my $tx = $frmMiddle->Text(-yscrollcommand => ['set' => $scrollbar1],-width =>18,-height =>20,-background =>"white")->pack(-padx => 15,-pady => 10,-side => 'left',-fill =>'both',-expand =>1);
$scrollbar1->configure(-command => ['yview' => $tx]);
$scrollbar1->pack(-side => 'left', -fill => 'y');

my $tx1 = $frmMiddle->Text(-yscrollcommand => ['set' => $scrollbar2],-width =>18,-height =>20,-background =>"white")->pack(-padx => 15,-pady => 10,-side => 'left',-fill =>'both',-expand =>1);
$scrollbar2->configure(-command => ['yview' => $tx1]);
$scrollbar2->pack(-side => 'left', -fill => 'y');

my $tx3 = $frmMiddle->Text(-yscrollcommand => ['set' => $scrollbar3],-width =>18,-height =>20,-background =>"white")->pack(-padx => 15,-pady => 10,-side => 'left',-fill =>'both',-expand =>1);
$scrollbar3->configure(-command => ['yview' => $tx3]);
$scrollbar3->pack(-side => 'left', -fill => 'y');

#bottom level frame....

my $frmBottom = $mw->Frame(-bd => 3, -relief => 'ridge')
->pack(-side => 'top', -fill => 'both');

$frmBottom->Button(-text => "Update", -command =>\&updating,-background => '#BC8F8F')->pack(-ipadx => 10,-ipady => 4,-padx => 15,-pady => 15,-side =>"left",-expand
=>"no",-anchor =>"w");

$frmBottom->Button(-text => "Close", -command =>sub{exit},-background => '#BC8F8F')->pack(-ipadx => 10,-ipady => 4,-padx => 15,-pady => 15,-side =>"right",-expand
=>"no",-anchor =>"e");

thanks for your time,cheers
Oct 21 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: sam | last post by:
I have a function writen in Perl that takes a name-value list (array) as argument and returns a name-value list (array). My question is: How to call this function from PHP and get the returned...
2
by: mksql | last post by:
New to Tkinter. Initially, I had some code that was executing button commands at creation, rather than waiting for user action. Some research here gave me a solution, but I am not sure why the...
2
by: James Hull | last post by:
Hi All: I am new in the Perl world. So far I have installed cygwin and Perl 5.8.0 along with Perl DBI and DBD::Oracle modules. NowI am trying to install Perl Tk on my PC (Windows 2K). I have...
10
by: Hendry Taylor | last post by:
I wrote a perl script and tested it on windows and it works fine. I then moved it onto a solaris machine and now it says that there is a syntax error with the following line of code: $user1 =...
19
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate...
0
by: Kirt Loki Dankmyer | last post by:
So, I download the latest "stable" tar for perl (5.8.7) and try to compile it on the Solaris 8 (SPARC) box that I administrate. I try all sorts of different switches, but I can't get it to compile....
14
by: Kevin | last post by:
A couple of easy questions here hopefully. I've been working on two different database projects which make use of multiple forms. 1. Where's the best/recommended placement for command buttons...
6
by: surfivor | last post by:
I may be involved in a data migration project involving databases and creating XML feeds. Our site is PHP based, so I imagine the team might suggest PHP, but I had a look at the PHP documentation...
10
by: happyse27 | last post by:
Hi All, I got this apache errors(see section A1 and A2 below) when I used a html(see section b below) to activate acctman.pl(see section c below). Section D below is part of the configuration...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.