Hi!
I tryed this script to non blocked read in tk - use Tk;
-
use Term::ReadKey;
-
-
ReadMode 4, STDIN;
-
$in = \*STDIN;
-
-
$mw=MainWindow->new();
-
$mw->maxsize(500,800);
-
$mw->minsize(500,800);
-
-
$text=$mw->Text( -width=>65,
-
-height=>5,
-
);
-
$text->place(-x => 20,-y => 700);
-
$text->focus();
-
-
$g2 = $mw->Button(-text => "Button",
-
-command => sub{ &rutin}
-
);
-
$g2->place(-x => 240, -y => 100);
-
-
Mainloop();
-
-
sub rutin
-
{
-
while(1)
-
{
-
$k = "";
-
$k=ReadKey(-1, $in);
-
if($k ne "")
-
{
-
$text->insert('insert',$k);
-
$text->focus();
-
last;
-
}
-
}
-
-
}
It doesnt work just if I change to the prompt shell and there hit a key.
Have anybody idea how possible take non blocked read whithout this
WIN XP, Active Perl 5.10
9 1883
Hi!
I tryed this script to non blocked read in tk - use Tk;
-
use Term::ReadKey;
-
-
ReadMode 4, STDIN;
-
$in = \*STDIN;
-
-
$mw=MainWindow->new();
-
$mw->maxsize(500,800);
-
$mw->minsize(500,800);
-
-
$text=$mw->Text( -width=>65,
-
-height=>5,
-
);
-
$text->place(-x => 20,-y => 700);
-
$text->focus();
-
-
$g2 = $mw->Button(-text => "Button",
-
-command => sub{ &rutin}
-
);
-
$g2->place(-x => 240, -y => 100);
-
-
Mainloop();
-
-
sub rutin
-
{
-
while(1)
-
{
-
$k = "";
-
$k=ReadKey(-1, $in);
-
if($k ne "")
-
{
-
$text->insert('insert',$k);
-
$text->focus();
-
last;
-
}
-
}
-
-
}
It doesnt work just if I change to the prompt shell and there hit a key.
Have anybody idea how possible take non blocked read whithout this
WIN XP, Active Perl 5.10
Change This: - $g2 = $mw->Button(-text => "Button",
-
-command => sub{ &rutin}
-
);
to: - $g2 = $mw->Button(-text => "Button",
-
-command => sub \&rutin
-
);
You can't say "sub \&rutin". "sub" needs brackets - sub {anonymous function};
-
-
sub named_function {
-
....
-
}
So this will work: - $command = sub {&foo};
-
$command->();
-
sub foo {
-
print "here we are";
-
}
-
and this will work the same - $command = \&foo;
-
$command->();
-
sub foo {
-
print "here we are";
-
}
My Bad, I made a mistake it was meant to be - $g2 = $mw->Button(-text => "Button",
-
-command => \&rutin
-
);
Thank you for picking that up kevin
My Bad, I made a mistake it was meant to be - $g2 = $mw->Button(-text => "Button",
-
-command => \&rutin
-
);
Thank you for picking that up kevin
"Experts" are allowed two mistakes a year otherwise they get demoted to "Amatuer". ;)
Also Mainloop(); is wrong
Case its meant to be MainLoop(); with the upper case L in Loop.
"Experts" are allowed two mistakes a year otherwise they get demoted to "Amatuer". ;)
at least i found the problem :P
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Jay Vinton |
last post by:
I recently posted my first .aspx effort and am getting calls from users
saying the page is being blocked and they can't view it. They got a hyperlink
in an e-mail (see below). Most have been...
|
by: jfradette |
last post by:
Hello, all of my JavaScript are blocked by the latest version of
Explorer. What can I add to my scripts to prevent browsers from
blocking it? I am using scripts for a drop-down menu to jump to a...
|
by: laurenq uantrell |
last post by:
In master.dbo.sysprocesses I can filter for blocked users (Blocked >0)
and I can create a self join(ON SPID = Blocked) to see what user
Loginame is causing the block. In the column I can see the...
|
by: Yim |
last post by:
In below codes,
After 10 seconds, function t() was called. So far everything is ok.
Then I want to awake blocked read(). So want to exit program.
In t(), how to do?
(in t(), close(sockfd) don't...
|
by: Dr. J |
last post by:
How to terminate a blocked thread?
In my form's "load" I launch a TCP listening thread that stays in an
infinite loop waiting for incoming TCP packets. In this form's "closing" I
try to...
|
by: Qindong Zhang |
last post by:
My socket application blocked at socket.receiver() after received all
information from sender. Should socket.Receive() return 0 after no
more data available? Note: My socket object was not close on...
|
by: MrS4T4n |
last post by:
Hi!
I wrote a windows service, this service read a txt file and make some
task... the service works at 00:00, 00:30, 01:00, 01:30 etc... (every
half hour)
The problem is the txt, there is a...
|
by: dd |
last post by:
I have a scenario where my popups are being blocked
by IE6+ and Firefox. The problem is that although the
popup is a direct result of the user clicking on the link
(meaning that they WANT the...
|
by: Damien582 |
last post by:
Hi everyone,
I am working with a library (HIDLibrary) to read from and hid device (eHome Infraread Transceiver, aka Windows Media Center Remote) to read from a universal remote control. The...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
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...
| |