RosettaCodeData/Task/User-input-Graphical/Nanoquery/user-input-graphical.nanoquery

57 lines
1.3 KiB
Plaintext

import Nanoquery.Util.Windows
// a function to handle the main window closing
def finish(caller, event)
exit
end
// create a window
w = new(Window, "Input").setTitle("Input")
w.setSize(320, 190)
w.setHandler(w.closing, finish)
// create two labels to go next to the input boxes
stringlabel = new(Label).setParent(w)
intlabel = new(Label).setParent(w)
stringlabel.setText("String: "); stringlabel.setPosition(20, 25)
intlabel.setText("Integer: "); intlabel.setPosition(20, 75)
// create two textboxes for input
stringbox = new(Textbox).setParent(w)
intbox = new(Textbox).setParent(w)
stringbox.setPosition(100, 20); stringbox.setWidth(200); stringbox.setHeight(30)
intbox.setPosition(100, 70); intbox.setWidth(200); intbox.setHeight(30)
// a function that handles when the 'done' button is clicked
def done_clicked(caller, event)
global stringbox
global intbox
global w
s = stringbox.getText()
i = intbox.getText()
try
if int(i) = 75000
println "String: " + s
println "Integer: " + i
exit
else
w.showMessageBox("Please enter 75000 for the integer value")
end
catch
w.showMessageBox("Please enter 75000 for the integer value")
end
end
// create the 'done' button
done = new(Button).setParent(w)
done.setText("Done"); done.setPosition(250,120)
done.setHandler(done.clicked, done_clicked)
// display the window
w.show()