Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Can't get Dialog or messageBox to work from button

by hotchiwawa (Scribe)
on Jan 11, 2016 at 15:18 UTC ( [id://1152487]=note: print w/replies, xml ) Need Help??


in reply to Can't get Dialog or messageBox to work from button

Try with:
$f_refresh->Button(-text => 'Test', -command => sub { &displayMsg()})- +>pack(-side=>'left');
Call all your functions in Tk with the & or \& prefix if they are defined after their call. Perl can't find them. ;)

Edit
Some call examples:

Here inside an anonymous subroutine: end_automode and ping_site are called.
$update_bttn = $button_f->Button(-text => "Update", -state => 'disabled', -command => sub { &end_automode; &ping_site });
Here a direct call to the subroutine do_automode, bind to the command.
$automode_bttn = $button_f->Button(-text => "Start Automode", -command => \&do_automode);
Rem: end_automode, ping_site, do_automode are defined after their calls.

Replies are listed 'Best First'.
Re^2: Can't get Dialog or messageBox to work from button
by choroba (Cardinal) on Jan 11, 2016 at 15:49 UTC
    Sure!
    sub xx { shift() + 1 } say \&xx(3); # SCALAR(0x60003b660) say ${ \&xx(3) }; # 4 say sub { \&xx(shift) }->(3); # SCALAR(0x60003b888) say ${ sub { \&xx(shift) }->(3) }; # 4
    How much easier than
    say xx(3); # 4 say sub { xx(shift) }->(3); # 4
    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

      I don't use Tk and therefore i didn't really read the friendly manual but i would like to mention that i figured out in a hurry that the construct hotchiwawa mentions can be found here and here. Perhaps he jumped to the wrong conclusion?

      Best regards, Karl

      «The Crux of the Biscuit is the Apostrophe»

        I don't use Tk and therefore i didn't really read the friendly manual
        This is not Tk related. This is referencing in Perl.
        that the construct hotchiwawa mentions can be found here and here
        No, it can't. There's a big difference between the two:
        my $value_ref = \&callback(); my $code_ref = \&callback; # <-- See? No parentheses!
        ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
        I updated my 1st post with 2 examples yesterday ;)
        Interesting your doc.
Re^2: Can't get Dialog or messageBox to work from button
by Anonymous Monk on Jan 11, 2016 at 15:41 UTC
    Can you please explain that. Why would anyone "Call all your functions with the \& prefix" and what does it have to do with "they are under ;)"?
      I added info in the post.

        Why do you think that Perl couldn't find displayMsg? The debug output certainly shows that it was found and called. If Perl couldn't find a subroutine, it would have raised an error which the OP would have seen.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1152487]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-19 20:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found