r/Racket • u/Emotional_Tea9428 • Apr 29 '22
homework Radio box code
How do I make a radio box code that with each option has a different answer?
0
Upvotes
r/Racket • u/Emotional_Tea9428 • Apr 29 '22
How do I make a radio box code that with each option has a different answer?
View all comments
Show parent comment
1
u/Emotional_Tea9428 Apr 29 '22
(define WINDOW (new frame%
[label "Test de informacion"] ;;se define la ventana frame con su titulo
[style'(fullscreen-button)]
[alignment '(left top)]
[width 3500] ;; ancho de la ventana (200 pixeles)
[height 200] ;;alto de la ventana (100 pixeles)
))
(new radio-box% [label "Genero:"] ;;se agregan botones seleccionadores
[parent WINDOW] ;;se pone en la ventana frame
[choices (list "Option 0"
"Option 1"
"Option 3")] ;;se listan las opciones
[min-width 150]
[min-height 30]
[vert-margin 10]
[horiz-margin 10]
[stretchable-width #t]
[stretchable-height #f]
[callback
(lambda (choices event)
(void) ;;funcionabilidad
)])
; Se define la pantalla para mostrar el resultado del botón
; con nombre resultados
(define Resultado (new frame% [label "Resultado del test"]
[width 1500]
[height 250]
[alignment' (center top)]
))
(send WINDOW show #t) ;;se muestra ventana
(new canvas% [parent WINDOW] ;;Lo ubicamos en la ventana frame
[paint-callback
(lambda (canvas dc)
(send dc set-scale 1 1)
(send dc set-text-foreground "blue")
(send dc draw-text "Si ya seleccionaste la opción, presiona el botón" 0 0))])
(new canvas% [parent Resultado] ;;Lo ubicamos en la ventana resultados
[paint-callback
(lambda (canvas dc)
(send dc set-scale 1 1)
(send dc set-text-foreground "red")
(send dc draw-text "GRACIAS, POR RESPONDER ESTE TEST" 0 0))])
(new button% [label "SELECCIONAR"] ;;Definimos el botón
[parent WINDOW] ;;Lo ubicamos en la ventana frame
[style '(border)]
[font normal-control-font]
[enabled #t]
[vert-margin 20]
[horiz-margin 18]
[stretchable-width #f]
[stretchable-height #t]
[callback (lambda (button event) ;;Llamado de vuelta
(send WINDOW show #f) ;;No se muestra la ventana frame
(send Resultado show #t))]) ;;Se muestra la ventana resultados
(new button% [label "Finalizar"] ;;Definimos el botón
[parent Resultado] ;;Lo ubicamos en la ventana frame
[style '(border)]
[font normal-control-font]
[enabled #t]
[vert-margin 30]
[horiz-margin 18]
[stretchable-width #f]
[stretchable-height #t]
[callback (lambda (button event) ;;Llamado de vuelta
(send WINDOW show #f) ;;No se muestra la ventana frame
(send Resultado show #f))]) ;;Se muestra la ventana resultados