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 Nanoquery.Util.Windows
 
// define the necessary objects
$w = new("Window")
$b = new("Button")
$l = new("Label")
 
$b.setParent($w)
$l.setParent($w)
 
// define the amount of clicks
$clicks = 0
 
// a function to update the label
def updateLabel($caller, $event)
        global $clicks
        global $l
 
        $clicks = $clicks+1
        $l.setText(str($clicks))
 
        global $clicks = $clicks
end
 
// prepare the components to be displayed
$w.setSize(200,200)
$b.setText("click me")
$b.setPosition(0,100)
$l.setText("There have been no clicks yet")
 
// set the button's event handler to the function updateLabel 
$b.setHandler($updateLabel)
 
// show the window
$w.show()