simpledialog.rkt 631 B

123456789101112131415161718192021
  1. #lang racket/gui
  2. ; Create a dialog
  3. (define dialog (instantiate dialog% ("Example")))
  4. ; Add a text field to the dialog
  5. (new text-field% [parent dialog] [label "Your name"])
  6. ; Add a horizontal panel to the dialog, with centering for buttons
  7. (define panel (new horizontal-panel% [parent dialog]
  8. [alignment '(center center)]))
  9. ; Add Cancel and Ok buttons to the horizontal panel
  10. (new button% [parent panel] [label "Cancel"])
  11. (new button% [parent panel] [label "Ok"])
  12. (when (system-position-ok-before-cancel?)
  13. (send panel change-children reverse))
  14. ; Show the dialog
  15. (send dialog show #t)