<HTML>
<HEAD><TITLE> 11.8. How do I ring the bell?</TITLE></HEAD>
<BODY><a name="A11.8"> 11.8. How do I ring the bell?</a>
<hr>
</p><p>
The short answer is
<pre>
$<i>widget</i> -> bell;
</pre>
A slightly longer answer might include a fully functioning script:
<pre>
#!/usr/bin/perl
use Tk;
$main = MainWindow -> new;
$butn = $main->Button(-text => 'bell')
$butn->configure(-command => sub{ $butn->bell; });
$butn->pack();
MainLoop;
</pre>
An even longer answer would be a <A HREF="etc/bellit">fully functioning script with a callback</A>:
<PRE>
#!/usr/bin/perl
use Tk;
$main = MainWindow -> new;
$but = $main->Button(-text => 'bell',
-command => sub{ringit($main)})->pack;
MainLoop;
sub ringit {
my $m = shift;
$m->bell;
}
</PRE>
Simon Galton <A HREF="mailto:galtons@candu.aecl.ca"><galtons@candu.aecl.ca></A>
reminds us to be careful in that
<BLOCKQUOTE>
some systems remap this [the "console bell"] to anything from a digital sound
to a flash on the screen.
</BLOCKQUOTE>
<hr>
<p><a href="qna11.7.html">Previous</a> | Return to <a href="ptkTOC.html#TOC11.8">table of contents</a> | <a href="qna11.9.html">Next</a>
</p><hr><p>
</BODY></HTML>