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 gtk2
 
nim_init()
 
var
  win = windowNew WINDOW_TOPLEVEL
  button = buttonNew "Click me"
  label = labelNew  "There have been no clicks yet"
  vbox = vboxNew(true, 1)
  counter = 0
 
proc clickedMe(o: var PButton, l: PLabel) =
  inc counter
  l.setText "You clicked me " & $counter & " times"
 
win.setTitle "Click me"
vbox.add label
vbox.add button
win.add vbox
discard win.signal_connect("delete-event", SignalFunc mainQuit, nil)
discard button.signal_connect("clicked", SignalFunc clickedMe, label)
win.showAll()
main()