Hello World II

Our Hello World program page was optimised to be comprehensible, but sometimes it is preferable to have it short.

To load the Tk extensions, enter

(require-extension tk)
(start-tk)

This expression creates another “Hello World” application. It does not use any global variable:

(tk/pack
  (tk 'create-widget 'button
      #:text 'Howdy!
      #:command (lambda () (print "Greetings Earthlings!")))
  (tk 'create-widget 'button
      #:text 'Exit
      #:command (lambda () (end-tk)))
  #:expand #t
  #:fill 'both)

Double size, half the price:

ButtonHowdyExit

Now test it:

(event-loop)

When anonymous, buttons can work as well!

screenTextHowdy

See also tk, create-widget, button, tk/pack.


© Author | Home | Sitemap