Buton With Maya

hello

how created a bouton in maya and programming ?
if i click in the buton a event happens
example: if i click in the buton a body appears in the scene
help me please

CODE
string $result = confirmDialog -title "Confirm" -message "Make a ball?"
    -button "Yes" -button "No" -defaultButton "Yes"
    -cancelButton "No" -dismissString "No"
;

if ($result == "Yes") {sphere;};