markus.pfeiffer
2019-9-4 10:20:09

Just saw this tweet: https://twitter.com/spdegabrielle/status/1169192205371793409 and had tried the map widget last night for unlreated reasons (trying to write my own widget..)


markus.pfeiffer
2019-9-4 10:20:13

this is so great :wink:


soegaard2
2019-9-4 10:22:16

@alexharsanyi Impressive!


spdegabrielle
2019-9-4 10:22:31

It was done by @alexharsanyi - his post is at https://groups.google.com/d/msg/racket-users/pzy1jv1s61o/Od78DTdcBQAJ


markus.pfeiffer
2019-9-4 10:25:38

My custom widget needs are quite a bit more pedestrian, but maybe I can learn some things from that code :wink:


markus.pfeiffer
2019-9-4 10:37:06

I assume there’s not very much else in the way of widgets for #racket/gui other than the map widget and the builtin ones? Googling for this kind of things is becoming increasingly hard (no I do not want to buy a tennis racket..)


soegaard2
2019-9-4 10:37:54

soegaard2
2019-9-4 10:38:39

If there is a particular type of widget, you can’t find, it is always a good idea to ask. For common widget types, odds are that someone has needed it before you.


soegaard2
2019-9-4 10:39:38

If I remember correctly “gui” is better search term than widget on pkgs.racket-lang.


markus.pfeiffer
2019-9-4 10:42:29

yesterday I was looking for a colour-picker of some description (doesn’t need to be fancy either at the moment)


soegaard2
2019-9-4 10:43:01

I am almost sure there is one in gui.


markus.pfeiffer
2019-9-4 10:44:11

its alwasy possible i am too daft to look properly of course


soegaard2
2019-9-4 10:44:29

Not at all. I can’t find it in the gallery.


soegaard2
2019-9-4 10:47:13

After gui I always look in framework: https://docs.racket-lang.org/framework/index.html?q=color%25 (Can’t find the color picker though)


soegaard2
2019-9-4 10:48:34

get-color-from-user


soegaard2
2019-9-4 10:48:38

It was in gui.



markus.pfeiffer
2019-9-4 10:50:24

yeah, that’s a modal dialogue though


markus.pfeiffer
2019-9-4 10:51:27

I am making a control program for Zigbee lights; right now I am just using sliders which works, but is a bit awkward


soegaard2
2019-9-4 10:51:29

Oh, you need something that can be part of a window.


markus.pfeiffer
2019-9-4 10:52:04

maybe it’s “easy” to make (for varying values of easy)


soegaard2
2019-9-4 10:56:45

Do macOS/Windows/Linus have standard color pickers? If so the task is somewhat involved.


markus.pfeiffer
2019-9-4 10:57:25

well, I don’t need the environment-specific one, I could make a CIE-xy picker


markus.pfeiffer
2019-9-4 10:58:03

I think this sholdn’t be too hard (tm), mostly need to translate coordinates on the widget into the x-y values and draw the correct colours into the widget


markus.pfeiffer
2019-9-4 10:58:17

yes more work than I’d hoped, but not an impossible task :wink:


markus.pfeiffer
2019-9-4 10:58:30

and I enjoy coding in racket way too much to dread the prospect of some hacking


soegaard2
2019-9-4 11:02:23

Maybe @alexharsanyi know of one?


soegaard2
2019-9-4 11:07:18

The code for get-color-from-user has a fallback which is used on platforms with no system color picker. That part of the code could be reused without problems as far as I can see.

https://github.com/racket/gui/blob/001c57b86c624ad367354d6bf168f55f82e79c20/gui-lib/mred/private/moredialogs.rkt#L305


soegaard2
2019-9-4 11:07:46

Line 306–307 uses the system color picker, and the 308- has the fallback.


markus.pfeiffer
2019-9-4 11:13:19

oh cool


markus.pfeiffer
2019-9-4 11:13:27

thanks, @soegaard2


markus.pfeiffer
2019-9-4 11:15:45

I can use that and even play with changing it a bit.


alexharsanyi
2019-9-4 12:37:38

Thanks. This was really an exercise in moving code around and implementing two interfaces: one for canvas% and one for snip%. The map drawing code is essentially the same. The reason that it worked with so little effort is because of the solid design of the racket gui library.


alexharsanyi
2019-9-4 12:42:59

I have implemented a few widgets of my own for my application, but they are not in separate packages. Not sure what widgets you are after, but you can take inspiration from here: https://github.com/alex-hhh/ActivityLog2/tree/master/rkt/widgets — there is also a readme file explaining what each one does.


alexharsanyi
2019-9-4 12:47:26

You can use the get-color-from-user function from the Racket GUI library. It uses the platform specific color picker,