Re: [racket-users] Enabling/disabling menu items

2019-06-11 Thread James Platt


On Jun 11, 2019, at 4:54 PM, Matthew Flatt wrote:

> At Tue, 11 Jun 2019 16:45:05 -0400, James Platt wrote:
>> It looks like there is not way to enable and disable (grey out) menu
>> items the way that there is with buttons.
> 
> There's no `enable` initialization argument for `menu-item%`, but
> there's an `enable` method the same as for `button%` instances. If
> would be nice to have an `enable` initialization argument to create an
> initially disabled menu item, but you can send `enable` just after
> creating the menu item.
> 
> Is that what you were looking for, or do you have something else in
> mind?

Thanks.  I think this will work for me but, yes, it would be nice to have the 
initialization argument.  That was what threw me off into thinking that it 
wasn't available.  

James

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/BEA1A70C-69B1-44CC-ACA8-7A18992054EB%40biomantica.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Enabling/disabling menu items

2019-06-11 Thread Matthew Flatt
At Tue, 11 Jun 2019 16:45:05 -0400, James Platt wrote:
> It looks like there is not way to enable and disable (grey out) menu
> items the way that there is with buttons.

There's no `enable` initialization argument for `menu-item%`, but
there's an `enable` method the same as for `button%` instances. If
would be nice to have an `enable` initialization argument to create an
initially disabled menu item, but you can send `enable` just after
creating the menu item.

Is that what you were looking for, or do you have something else in
mind?

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/5d00151a.1c69fb81.49370.e241SMTPIN_ADDED_MISSING%40mx.google.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Enabling/disabling menu items

2019-06-11 Thread James Platt
It looks like there is not way to enable and disable (grey out) menu items the 
way that there is with buttons.  So my question is whether the expectation is 
that you add and remove items from a menu instead or is this a reasonable 
feature request for a new version of Racket?

To illustrate what I mean with buttons, I have taken the code recently posted 
on this list by Matthias for the 7 GUIs task 5 (CRUD) and modified it so that 
the buttons enable and disable depending on whether something is selected or 
not.  After something is selected, you can click inside the list-box but not on 
any item to deselect and disable the buttons.  I want this kind of behavior but 
for menu items as well as buttons.

#! /usr/bin/env gracket
#lang at-exp racket/gui

;; a create-read-update-deleted MVC implementation 

;; 
---
(define *data '("Emil, Hans" "Mustermann, Max" "Tisch, Roman"))
(define *selector "")
(define *selected *data) ;; selected = (filter select data)

(define (selector! nu) (set! *selector nu) (data->selected!))
(define (select s) (string-prefix? s *selector))
(define (data->selected!)  (set! *selected (if (string=? "" *selector) *data 
(filter select *data

(define-syntax-rule (def-! (name x ...) exp) (define (name x ...) (set! *data 
exp) (data->selected!)))
(def-! (create-entry new-entry) (append *data (list new-entry)))
(def-! (update-entry new-entry i) (operate-on i (curry cons new-entry) *data 
select *selected))
(def-! (delete-from i) (operate-on i  values))

#; {N [[Listof X] -> [Listof X]] [Listof X] [X -> Boolean] [Listof X] -> 
[Listof X]}
;; traverse list to the i-th position of selected in data, then apply operator 
to rest (efficiency)
;; ASSUME selected = (filter selector data)
;; ASSUME i <= (length selected)
(define (operate-on i operator (data *data) (select select) (selected 
*selected))
  (let sync ((i i) (data data) (selected selected))
(if (select (first data))
(if (zero? i)
(operator (rest data))
(cons (first data) (sync (sub1 i) (rest data) (rest selected
(cons (first data) (sync i (rest data) selected)

;; 
---
(define-syntax-rule (def-cb (name x) exp ...) (define (name x _y) exp ... (send 
lbox set *selected)))
(def-cb (prefix-cb field) (selector! (if (string? field) field (send field 
get-value
(def-cb (Create-cb _b) (create-entry (retrieve-name)))
(def-cb (Update-cb _b) (common-cb (curry update-entry (retrieve-name
(def-cb (Delete-cb _b) (common-cb delete-from))

(define (common-cb f) (define i (send lbox get-selection)) (when i (f i)))
(define (retrieve-name) (string-append (send surname get-value) ", " (send name 
get-value)))
(define (lbox-click-action lstbox ctlevent)
  (cond [(null? (send lstbox get-selections))
 (send update-button enable #f)
 (send delete-button enable #f)]
[else (send update-button enable #t)
 (send delete-button enable #t)])
  )
;; 
---
(define frame   (new frame% [label "CRUD"]))
(define hpane1  (new horizontal-pane% [parent frame][border 10][alignment 
'(left bottom)]))
(define vpane1  (new vertical-pane% [parent hpane1]))
(new text-field% [parent vpane1][label "Filter prefix: "][init-value 
""][callback prefix-cb])
(define lbox(new list-box% [parent vpane1][label #f][choices '()][min-width 
100][min-height 100] [callback lbox-click-action]))
(define vpane2  (new vertical-pane% [parent hpane1][alignment '(right center)]))
(define name(new text-field% [parent vpane2][label "Name:  
"][init-value ""][min-width 200]))
(define surname (new text-field% [parent vpane2][label "Surname: "][init-value 
""][min-width 200]))
(define hpane2  (new horizontal-pane% [parent frame]))
(define create-button (new button% [label "Create"][parent hpane2][callback 
Create-cb]))
(define update-button (new button% [label "Update"][parent hpane2][callback 
Update-cb][enabled #f]))
(define delete-button (new button% [label "Delete"][parent hpane2][callback 
Delete-cb][enabled #f]))

(prefix-cb "" '***)
(send frame show #t)

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/6545DE0C-5B87-4C62-AF28-3C2C5A201627%40biomantica.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] scopes across files

2019-06-11 Thread Eric Griffis
On Thu, Jun 6, 2019 at 12:19 AM Fastmail  wrote:
>
> The `implement` macro needs to place its identifiers (say, `say`) inside
> the lexical context of the calling site, so that they bind other code
> coming in from the calling site (for instance, `(say 'hello)`).

Thanks! This was incredibly helpful. Swimming in a soup of phase-1 details, I
forgot which way is up -- in this case, toward the caller's context.

It's too easy to lose sight of the forest for the trees at this part of the
journey.

Eric

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAORuSUzYJL87NdTFLcb27pdMRe2yddD6fdnO37O7Y5b0Zj0dHw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] `fontconfig` through the FFI: best practice?

2019-06-11 Thread Matthew Butterick
If I want to call functions in the `fontconfig` library through the FFI, 

should I be relying on the incantations in "cairo-lib.rkt"?  [1] 

Or are those somehow specific to the `racket/draw` system? 

Why does the `fontconfig-lib` definition there include libraries that are not 
`libfontconfig`? 

Does the "Racket-specific patch to Fontconfig" need to be used always?

So far I've gotten some Fontconfig code to work on Racket 7.1 @ Mojave but it 
failed on 7.1 @ Sierra. So there is some platform-specific magic I'm missing. 

[1] 
https://github.com/racket/draw/blob/6ada7d8abdc664b4b4b42c6e2a7a3703d3794f9e/draw-lib/racket/draw/unsafe/cairo-lib.rkt
 


-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/54B670E7-D324-4EDB-92A1-E269CBBAA92A%40mbtype.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Re: nannou

2019-06-11 Thread Matthias Felleisen

big-bang is intended for beginners. I understand that it can be used beyond the 
intended course material but I want to say that “adult programmers” are better 
off with the underlying graphics tool box :) 



> On Jun 11, 2019, at 8:10 AM, Darren Newton  wrote:
> 
> I spent a couple of weeks working through Daniel Shiffman's The Nature of 
> Code 
> 
>  approximating Processing with Typed Racket. It was pretty fun, but I had to 
> work up a lot of basics on my own (and also moved from an OO to functional 
> design using Big Bang). It would be very cool indeed to see a more fully 
> featured creative graphics platform develop in Racket. 
> 
> On Tuesday, June 11, 2019 at 1:35:59 AM UTC-4, Neil Van Dyke wrote:
> A platform for multimedia artist programmers is using Rust.  I think 
> it'd be interesting to see how what has been and could be done in Racket 
> (including DSLs) could compare.  https://nannou.cc/  
> 
> 
> -- 
> 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 
> .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/ac00bfbb-e48b-4882-93b5-b0a90de2318e%40googlegroups.com
>  
> .
> For more options, visit https://groups.google.com/d/optout 
> .

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/E5036E1B-FD14-44CC-8EF1-959FFF42EA81%40felleisen.org.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Re: nannou

2019-06-11 Thread Darren Newton
I spent a couple of weeks working through Daniel Shiffman's The Nature of 
Code 

 
approximating Processing with Typed Racket. It was pretty fun, but I had to 
work up a lot of basics on my own (and also moved from an OO to functional 
design using Big Bang). It would be very cool indeed to see a more fully 
featured creative graphics platform develop in Racket. 

On Tuesday, June 11, 2019 at 1:35:59 AM UTC-4, Neil Van Dyke wrote:
>
> A platform for multimedia artist programmers is using Rust.  I think 
> it'd be interesting to see how what has been and could be done in Racket 
> (including DSLs) could compare.  https://nannou.cc/ 
>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/ac00bfbb-e48b-4882-93b5-b0a90de2318e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Re: grammar-based fuzzing

2019-06-11 Thread zeRusski
cool wasn't aware of Xsmith! Surprised to find RACR backing it - I looked 
at its source a while back for some attribute grammar magic - ended up not 
doing anything though - was it lack of docs - can't recall. IIRC it has 
some true scheme magic in there.

Academics often suck at marketing ;) For those who, like me, were 
interested but failed to navigate to relevant bits:
- Xsmith docs: https://docs.racket-lang.org/xsmith/index.html
- Xsmith src: https://gitlab.flux.utah.edu/xsmith/xsmith
- RACR docs: 
https://github.com/christoff-buerger/racr/blob/master/racr/documentation/contents.md
- RACR src: https://github.com/christoff-buerger/racr

On Thursday, 6 June 2019 21:41:21 UTC+1, Eric Eide wrote:
>
> Ryan Kramer > writes: 
>
> > Does Racket have any grammar-based fuzzing utilities? 
>
> You might be interested in Xsmith.  Version 1.0 will be released 
> imminently, 
> like within the next week.  I'll send another email when it's released. 
>
> Stay tuned! 
>
> -- 
> ---
>  
>
> Eric Eide >  . University of Utah 
> School of Computing 
> http://www.cs.utah.edu/~eeide/ . +1 (801) 585-5512 voice, +1 (801) 
> 581-5843 FAX 
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/f46560e1-2f64-499f-96a1-c4ac0e465a1b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Re: [ann] marionette: control Firefox from Racket

2019-06-11 Thread zeRusski
Brilliant! Thank you for this

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/f258c49e-838a-4013-b730-172beabf4024%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.