<?xml version="1.0" encoding="windows-1252"?>
<node id="874300" title="Re: Popup window for asking a question" created="2010-11-29 12:09:42" updated="2010-11-29 12:09:42">
<type id="11">
note</type>
<author id="131741">
zentara</author>
<data>
<field name="doctext">
Here is a basic example.
&lt;c&gt;
#!/usr/bin/perl -w
use strict;
use warnings;

use Tk;

my $mw = MainWindow-&gt;new();
$mw-&gt;withdraw();

my $ftp_warn = $mw-&gt;messageBox(
  -title   =&gt; 'Silly message',
  -message =&gt; "We are displaying a silly message, do you wish to continue?",
  -type    =&gt; 'YesNo',
  -icon    =&gt; 'question',
);

if ( $ftp_warn eq 'No' ) {
  exit;

  }else {
    my $msg2 = $mw-&gt;messageBox(
    -title   =&gt; 'Really?',
    -message =&gt; "We displayed silly message and you wish to continue?",
    -type    =&gt; 'OK',
    -icon    =&gt; 'question',
  );

while (1){
print "hit control-c to exit\n";
sleep 1;
}

}

&lt;/c&gt;
and here is a little right click popup that can be very handy.
&lt;c&gt;
#!/usr/bin/perl
use warnings;
use strict;

#set up main window display
use Tk;
my $mw = new MainWindow(-title =&gt; 'PopUp');
my @buttons = qw(A B C D E F G);

#popup menu set up
my $popupmenu = $mw-&gt;Menu(-tearoff =&gt; 0);

    foreach my $bt (reverse @buttons){
            $popupmenu-&gt;insert(0, 'command',
               -label =&gt; $bt,
               #-command =&gt; [sub {print $popupmenu-&gt;cget('text') ."\n"}],
               -command =&gt; [sub {print $bt ."\n"}],
          );
    }


$mw-&gt;bind("&lt;Button-3&gt;" =&gt; sub {$popupmenu-&gt;Popup(-popover =&gt; "cursor",
                                    -popanchor =&gt; 'nw'),
                                -command =&gt; [sub {print "Popup\n"}]});


MainLoop();

&lt;/c&gt;


&lt;!-- Node text goes above. Div tags should contain sig only --&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-131741"&gt;
&lt;hr /&gt;
I'm not really a human, but I play one on earth.&lt;br&gt;
[id://630805] ................... &lt;a href=http://zentara.net/japh.html&gt; flash japh &lt;/a&gt;

&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
874276</field>
<field name="parent_node">
874276</field>
</data>
</node>
