@mark.warren Looking at the games directory was quite useful! Thanks for suggesting that. Now I’ve finally seen “real” Racket code. I had no idea how much Racket source code was already on my hard drive.
@bkovitz you might also like https://alex-hhh.github.io/2018/10/chess-game-using-racket-s-pasteboard.html
@samth Whoa, this looks great! Might be just what the doctor ordered. I learned how to make GUIs in Borland C++ from their example chess app. But theirs was a lot longer than 162 lines!
racket/gui question: If you have a frame% with two canvases in it, one above the other, how can you add a widget that the user can drag to change the proportion of space given to each canvas?
There seems to be a panel:splitter-mixin
, but I haven’t understood how to use it. https://docs.racket-lang.org/framework/Panel.html#%28def._%28%28lib._framework%2Fmain..rkt%29._panel~3asplitter-mixin%29%29
@bkovitz If I understand what you want to correctly, I think you want panel:vertical-dragable%
or panel:vertical-dragable-mixin
: http://docs.racket-lang.org/framework/Panel.html?q=#%28def._%28%28lib._framework%2Fmain..rkt%29._panel~3avertical-dragable~25%29%29
(I don’t think I understand panel:splitter-mixin
either.)
Thanks. I was looking at those earlier today and wasn’t quite sure how to use them. I’ll have another look right now. Maybe my Racket chops have improved since then. :wink:
@bkovitz Here’s a little example: #lang racket/gui
(require framework)
(let* ([f (new frame%
[label "Example"]
[width 400]
[height 400])]
[p (new panel:vertical-dragable%
[parent f])])
(define (add-child label)
(new message%
[label label]
[parent (new group-box-panel%
[label label]
[alignment '(center center)]
[parent p])]))
(add-child "A")
(add-child "B")
(send f show #t))
Thanks! I’ll try that right now. Aha, I already see that there should be only one such panel.
That was it. One tiny change did it:
(That’s at the end of a frame% class definition.)
Hooray!
Say, in a REPL run from racket -i
, how can you “cd” into a module, as if you were in DrRacket?
You want enter!
: http://docs.racket-lang.org/reference/interactive.html
Ah, it does exist! Thanks. I just tried it.
It’s also built into XREPL as the ,enter [<module>] [noisy?]
“meta command": http://docs.racket-lang.org/xrepl/index.html?q=xrepl#%28xrepl._enter%29
Excellent. It’s starting to look like working in racket -i
is actually very practical.
readline even works as expected. I’m used to vim’s key bindings, so this is really good.
I just found the ^, ^^, etc. variables. How did I ever live without XREPL? :smile:
@bkovitz No problem, glad to be of help.