Task

Create a window that has:

   a label that says   "There have been no clicks yet" 
   a button that says   "click me"


Upon clicking the button with the mouse, the label should change and show the number of times the button has been clicked.




 
import gui
$include "guih.icn"
 
class SimpleApp : Dialog (label)
 
  # -- automatically called when the dialog is created
  method component_setup()
    # create and add the label
    label := Label("label=There have been no clicks yet","pos=50%,33%", "align=c,c")
    add (label)
 
    # create and add the button
    button := TextButton("label=Click me", "pos=50%,66%", "align=c,c")
    button.connect(self, "clicked", ACTION_EVENT)
    add (button)
 
    # some cosmetic settings for the window
    attrib("size=180,70", "bg=light gray")
  end
 
  method clicked ()
    static count := 0
    count +:= 1
    label.set_label ("Clicked " || count || " times")
  end
end
 
procedure main()
  local d := SimpleApp ()
  d.show_modal()
end
 