Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Understanding callbacks

by RichardK (Parson)
on Jun 13, 2015 at 16:25 UTC ( [id://1130307]=note: print w/replies, xml ) Need Help??


in reply to Understanding callbacks

Have a look at Tk::UserGuide for examples of how a gui uses callbacks.

The first example is this :-

#!/usr/bin/perl -w use Tk; use strict; my $mw = MainWindow->new; $mw->Label(-text => 'Hello, world!')->pack; $mw->Button( -text => 'Quit', -command => sub { exit }, )->pack; MainLoop;

The program sets up the gui then calls MainLoop and never returns, only when the user clicks on the button will the callback -command get called.

Replies are listed 'Best First'.
Re^2: Understanding callbacks
by stevieb (Canon) on Jun 14, 2015 at 20:46 UTC

    I very much appreciate everyone's feedback in this thread, but I'm replying here as this post (after reading through the docs of Tk) showed me that I wasn't really trying to understand callbacks, but as a few stated, Event Driven Programming.

    I just didn't correlate the two so deeply, but now I fully understand the purpose of a callback in non-event driven apps (grep was a *great* example for me to grasp).

    Although I don't have any need to do GUI programming, I am going to play around with it for a while so I can grasp this event-driven thing, as I want to fully understand how it works so perhaps one day I can incorporate some of their benefits into apps I do write on a daily basis.

    Again, thanks to all the Monks who replied with such in-depth and thought-out posts to help me understand not just about callbacks, but programming at another level.

    Thanks and regards,

    -stevieb

Log In?
Username:
Password:

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

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

    No recent polls found