Even though I'm new to Tk, I was pretty sure the above code wouldn't work. Sure enough, it doesn't. I'm guessing it's because the infinite loop, outside of the 'MainLoop,' never gets executed. So am I going to need a thread here? I've dabbled with threads in Java. But I'm not familiar with threading at all with Perl and I hear it's kind of a nightmare. Is there a more obvious technique I could be using that I'm missing?use strict; use Win32::Clipboard; use Tk; my $change_mode = \&change_mode; my $mode = 0; my $clip = Win32::Clipboard(); my $main = new MainWindow; $main->Label(-text => 'Clipboard Case Changer' )->pack; $main->Button(-text => 'On/Off Toggle', -command => $change_mode )->pack; MainLoop; sub change_mode { $mode = !$mode; } #Change clipboard contents to uppercase, if $mode == 1; while(1) { $clip->WaitForChange(); my $contents = $clip->Get(); if ($mode) { $clip->Set(uc($contents)); } }
$PM = "Perl Monk's";
$MCF = "Most Clueless Friar Abbot Bishop Pontiff";
$nysus = $PM . $MCF;
Click here if you love Perl Monks
In reply to Does this Tk program require a thread? by nysus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |