#lang racket/gui
(define frame (new frame% [label "Progress Bar"] [width 300]))
(define hpane (new horizontal-pane% [parent frame]))
(define gauge (new gauge% [label ""] [parent hpane] [range 100]))
(define msg (new message% [parent hpane] [auto-resize #t] [label "0%"]))
(send frame show #t)
(for ([i (in-range 1 101)]) (sleep 0.05) (send gauge set-value i) (send msg set-label (string-append (~a i) "%")))
(define (initialize-progress-bar) ;; insert code that creates progress bar ;; i.e., from defining frame to sending frame in code above)
(define (update-progress-bar new-value) (send gauge set-value new-value) (send msg set-label (string-append (~a new-value) "%")))
(initialize-progress-bar)(for ([i (in-range 1 101)]) (sleep 0.05) (update-progress-bar i))--
You received this message because you are subscribed to the Google Groups "Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to racket-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/61a3ea75-d285-45d1-90d4-de569c441c8d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
#lang racket/gui
(define (initialize-progress-bar) (define frame (new frame% [label "Progress Bar"] [width 300]))
(define hpane (new horizontal-pane% [parent frame]))
(define gauge (new gauge% [label ""] [parent hpane] [range 100]))
(define msg (new message% [parent hpane] [auto-resize #t] [label "0%"]))
(send frame show #t) (values gauge msg))
(define (update-progress-bar new-value) (send the-gauge set-value new-value) (send the-msg set-label (string-append (~a new-value) "%")))
(define-values (the-gauge the-msg) (initialize-progress-bar))(for ([i (in-range 1 101)]) (sleep 0.05) (update-progress-bar i))
There are several ways to solve this (including deriving classes), but the simplest for you right now is probably to have `initialize-progress-bar' return the gui widgets (in particular `gauge' and `msg'), assign the values to `the-gauge' and `the-msg' (say) from the return values of `(initialize-progress-bar)` call, and then pass these values to `update-progress-bar' so that `gauge' and `msg' have the correct values there.Does that make sense?
To unsubscribe from this group and stop receiving emails from it, send an email to racket...@googlegroups.com.
As always, I welcome people sharing alternative ways to write the same code.