Re: [racket-users] Bug in table-panel% ?
It does look like a problem with `table-panel%`, which maybe doesn't work when an instance is created in parent a window that is already shown. You may be able to work around the problem by adding [style '(deleted)] to `(new table-panel% ...)`, and then (send tab-panel add-child table-panel) after the `(initialize-widgets)` call. At Sun, 23 Apr 2017 14:34:11 -0700 (PDT), Zelphir Kaltstahl wrote: > I am creating a little hobby project with Racket GUI classes. For that I got > the following code, which creates a frame%: > > #lang racket/gui > > (require table-panel > "vocabulary.rkt") > (provide build-gui) > > > (define (clear-children an-area-container) > (for ([child (send an-area-container get-children)]) > (send an-area-container delete-child child))) > > > (define (build-gui) > ; Make a frame by instantiating the frame% class > (define frame (new frame% > [label "Example"] > [alignment (list 'center 'center)] > [min-width 320] > [min-height 240])) > (define tab-panel (new tab-panel% > [parent frame] > [choices (map (lambda (voc) > (get-vocabulary-identifier voc)) >VOCABULARY)] > [callback > (lambda (widget event) > (let* ([tab-selection-index (send tab-panel > get-selection)] >[tab-label (send tab-panel > get-item-label > tab-selection-index)]) > (set-tab-panel-content tab-panel tab-label)))])) > (define (set-tab-panel-content a-tab-panel a-label) > (clear-children a-tab-panel) > (define progress > (exact-floor >(* 100 > (get-vocabulary-learn-progress >(first (get-vocabularies-by-identifier a-label)) > (define progress-gauge > (new gauge% >[label (string-append "Progress (" (number->string (/ progress > 100.0)) "%): ")] >[range 1] >[parent a-tab-panel] >[min-width 100])) > (define table-panel > (new table-panel% > [parent tab-panel] > [alignment '(center center)] > [dimensions '(4 2)])) > (define (initialize-widgets) > (send progress-gauge set-value progress) > (for ((i (in-range 4))) > (let ([child-table (new table-panel% > [parent table-panel] > [style '(border)] > [dimensions (list 4 3)] > [column-stretchability (if (memq i '(0 1)) #t > #f)] > [row-stretchability (if (memq i '(0 2)) #t > #f)])]) > (for ([label-string (list "1" "2" "3" > "4" "5" "6" > "7" "8" "9" > "*" "0" "#")]) > (new button% > [parent child-table] > [label label-string] > [stretchable-width #t] > [stretchable-height #t] > [callback > (lambda (button event) > (displayln (send button get-label)))]) > (initialize-widgets)) > > (define (set-initial-gui-state) > (set-tab-panel-content tab-panel >(send tab-panel get-item-label 0))) > > ;; initialize things > (set-initial-gui-state) > > ;; return the frame > frame) > > When I `show` this frame using: > > (send frame show true) > > It at first renders the table-panel fine, but when I switch the tabs in the > tab-panel, I get weird errors: > > compute-sizes: undefined; > cannot use field before initialization > context...: >/home/xiaolong/.racket/6.8/pkgs/table-panel/main.rkt:340:4: container-size > method in table-panel% >/usr/share/racket/collects/racket/private/more-scheme.rkt:148:2: > call-with-break-parameterization >/usr/share/racket/pkgs/gui-lib/mred/private/wxcontainer.rkt:20:31: > get-graphical-min-size method in ...vate/wxcontainer.rkt:13:4 >/usr/share/racket/pkgs/gui-lib/mred/private/wxpanel.rkt:347:8: > get-min-size > method in .../private/wxpanel.rkt:71:4 >/usr/share/racket/pkgs/gui-lib/mred/private/wxitem.rkt:155:10: get-info > method in ...d/private/wxitem.rkt:34:6 >/usr/share/racket/pkgs/gui-lib/mred/private/wxpanel.rkt:255:8: > get-children-info method in .../private/wxpanel.rkt:71:4 >/usr/share/racket/pkgs/gui-lib/mred/private/wxcontainer.rkt:20:31: > get-graphical-min-size method in ...vate/wxcontainer.rkt:13:4 >/usr/share/racket/pkgs/gui-lib/mred/private/wxpanel.rkt:347:8: >
[racket-users] Bug in table-panel% ?
I am creating a little hobby project with Racket GUI classes. For that I got the following code, which creates a frame%: #lang racket/gui (require table-panel "vocabulary.rkt") (provide build-gui) (define (clear-children an-area-container) (for ([child (send an-area-container get-children)]) (send an-area-container delete-child child))) (define (build-gui) ; Make a frame by instantiating the frame% class (define frame (new frame% [label "Example"] [alignment (list 'center 'center)] [min-width 320] [min-height 240])) (define tab-panel (new tab-panel% [parent frame] [choices (map (lambda (voc) (get-vocabulary-identifier voc)) VOCABULARY)] [callback (lambda (widget event) (let* ([tab-selection-index (send tab-panel get-selection)] [tab-label (send tab-panel get-item-label tab-selection-index)]) (set-tab-panel-content tab-panel tab-label)))])) (define (set-tab-panel-content a-tab-panel a-label) (clear-children a-tab-panel) (define progress (exact-floor (* 100 (get-vocabulary-learn-progress (first (get-vocabularies-by-identifier a-label)) (define progress-gauge (new gauge% [label (string-append "Progress (" (number->string (/ progress 100.0)) "%): ")] [range 1] [parent a-tab-panel] [min-width 100])) (define table-panel (new table-panel% [parent tab-panel] [alignment '(center center)] [dimensions '(4 2)])) (define (initialize-widgets) (send progress-gauge set-value progress) (for ((i (in-range 4))) (let ([child-table (new table-panel% [parent table-panel] [style '(border)] [dimensions (list 4 3)] [column-stretchability (if (memq i '(0 1)) #t #f)] [row-stretchability (if (memq i '(0 2)) #t #f)])]) (for ([label-string (list "1" "2" "3" "4" "5" "6" "7" "8" "9" "*" "0" "#")]) (new button% [parent child-table] [label label-string] [stretchable-width #t] [stretchable-height #t] [callback (lambda (button event) (displayln (send button get-label)))]) (initialize-widgets)) (define (set-initial-gui-state) (set-tab-panel-content tab-panel (send tab-panel get-item-label 0))) ;; initialize things (set-initial-gui-state) ;; return the frame frame) When I `show` this frame using: (send frame show true) It at first renders the table-panel fine, but when I switch the tabs in the tab-panel, I get weird errors: compute-sizes: undefined; cannot use field before initialization context...: /home/xiaolong/.racket/6.8/pkgs/table-panel/main.rkt:340:4: container-size method in table-panel% /usr/share/racket/collects/racket/private/more-scheme.rkt:148:2: call-with-break-parameterization /usr/share/racket/pkgs/gui-lib/mred/private/wxcontainer.rkt:20:31: get-graphical-min-size method in ...vate/wxcontainer.rkt:13:4 /usr/share/racket/pkgs/gui-lib/mred/private/wxpanel.rkt:347:8: get-min-size method in .../private/wxpanel.rkt:71:4 /usr/share/racket/pkgs/gui-lib/mred/private/wxitem.rkt:155:10: get-info method in ...d/private/wxitem.rkt:34:6 /usr/share/racket/pkgs/gui-lib/mred/private/wxpanel.rkt:255:8: get-children-info method in .../private/wxpanel.rkt:71:4 /usr/share/racket/pkgs/gui-lib/mred/private/wxcontainer.rkt:20:31: get-graphical-min-size method in ...vate/wxcontainer.rkt:13:4 /usr/share/racket/pkgs/gui-lib/mred/private/wxpanel.rkt:347:8: get-min-size method in .../private/wxpanel.rkt:71:4 /usr/share/racket/pkgs/gui-lib/mred/private/wxitem.rkt:155:10: get-info method in ...d/private/wxitem.rkt:34:6 /usr/share/racket/pkgs/gui-lib/mred/private/wxpanel.rkt:255:8: get-children-info method in .../private/wxpanel.rkt:71:4 /usr/share/racket/pkgs/gui-lib/mred/private/wxpanel.rkt:287:8: do-graphical-size method in .../private/wxpanel.rkt:71:4 /usr/share/racket/pkgs/gui-lib/mred/private/wxpanel.rkt:347:8: get-min-size method in .../private/wxpanel.rkt:71:4 /usr/share/racket/pkgs/gui-lib/mred/private/wxitem.rkt:155:10: get-info method in ...d/private/wxitem.rkt
[racket-users] Re: Cut/copy/paste buggy in DrRacket 6.8 (on my dual boot system)
On Friday, April 21, 2017 at 1:35:12 AM UTC-7, Chris Klopfenstein wrote: > It seems that sometimes when pasting the clipboard in DrRacket (version 6.8), > it also gets pasted into another (wrong) place. It is very annoying. > > It also *seems* to occur when doing cut/paste in a different app (with > DrRacket open). > > I've experienced this in both Ubuntu (16.10 and 17.04) and Win10. This seems very strange. Could you give a specific example? Maybe steps to reproduce the problem? -- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] Is this a closure?
There's another sense of the word ``closure'' while still in the subject of computing but which is different from what you've understood so far. Your understanding and the sense of the word used by Matthias Felleisen and David Storrs is that of Peter Landin in 1964. In ``[t]he mechanical evaluation of expressions'', Peter Landin defines ``closure'' in the popular sense used in computing. (This is the earliest use of the word, as far as I know.) Also we represent the value of lambda-expression by a bundle of information called a "closure", comprising the lambda-expression and the environment relative to which it was evaluated. We must therefore arrange that such a bundle is correctly interpreted whenever it has to be applied to some argument. More precisely: a closure has an /environment part/ which is a list whose two items are: (1) an environment (2) an identifier or a list of identifiers, and a /control part/ which consists of a list whose sole item is [a lambda expression]. This is how most computer scientists use the word. Mathematicians on the other hand usually mean something else when it comes to ``closure''. For example, ``a group is an algebraic structure consisting of a set of elements equipped with an operation that combines any two elements to form a third element. The operation satisfies four conditions called the group axioms, namely /closure/, associativity, identity and invertibility.'' -- Wikipedia But this more mathematical sense is quite relevant in computing. The best example I know is that from Harold Abelson (and Gerald Sussman) in the Lisp Lectures of 1986. Abelson is the one that uses the term in this mathematical meaning, applying it to the design of functions. Here's every mention of the word in the lectures. ``So I almost took it for granted when I said that cons allows you to put things together. But it's very easy to not appreciate that, because notice, some of the things I can put together can themselves be pairs. And let me introduce a word that I'll talk about more next time, it's one of my favorite words, called closure. And by closure I mean that the means of combination in your system are such that when you put things together using them, like we make a pair, you can then put those together with the same means of combination. So I can have not only a pair of numbers, but I can have a pair of pairs.'' -- Harold Abelson, lecture 2B ``Compound Data'', 1986. Then again in the next lecture: ``And again just to remind you, there was this notion of closure. See, closure was the thing that allowed us to start building up complexity, that didn't trap us in pairs. Particularly what I mean is the things that we make, having combined things using cons to get a pair, those things themselves can be combined using cons to make more complicated things. Or as a mathematician might say, the set of data objects in List is closed under the operation of forming pairs. That's the thing that allows us to build complexity. And that seems obvious, but remember, a lot of the things in the computer languages that people use are not closed. So for example, forming arrays in basic and Fortran is not a closed operation, because you can make an array of numbers or character strings or something, but you can't make an array of arrays.'' -- Harold Abelson, lecture 3A, ``Henderson Escher Example'', 1986. A few lectures later, Gerald Sussman uses the term, but in the sense of Peter Landin. ``First of all, one thing we see, is that things become a little simpler. If I don't have to have the environment be the environment of definition for procedure, the procedure need not capture the environment at the time it's defined. And so if we look here at this slide, we see that the clause for a lambda expression, which is the way a procedure is defined, does not make up a thing which has a type closure and a attached environment structure. It's just the expression itself. And we'll decompose that some other way somewhere else.'' -- Gerald Sussman, lecture 7B, ``Metacircular Evaluator'', 1986. And the two last appearances of the word, Abelson calls our attention to the importance of the idea. ``The major point to notice here, and it's a major point we've looked at before, is this idea of closure. The things that we build as a means of combination have the same overall structure as the primitive things that we're combining. So the AND of two things when looked at from the outside has the same shape. And what that means is that this box here could be an AND or an OR or a NOT or something because it has the same shape to interface to the larger things.'' ``It's the same thing that allowed us to get complexity in the Escher picture