> In the coding above, how could I know if the user click "Cancel / OK" button ?
run the code, click OK, see what 's' prints
run the code click Cancel, see what 's' prints
run the code click 'X', see what 's' prints
run the code click 'esc', see what 's' prints
you should be able to work out the differences, and code for it accordingly