Hi Travis,

Den tir. 7. jul. 2020 kl. 00.18 skrev Travis Kiefer <kiefertra...@gmail.com
>:

> Thank you for the example links. The spreadsheet example gets closer to
> the right direction of a non-trivial example. What's missing from these is
> the ability to add styles to the elements... Background colors, gradients,
> box shadow, border around a container element, left align, right align, et
> cetera.
>

In general (not just in Racket) the styling is more difficult in a cross
platform gui.
Since a Racket GUI program needs to run on both macOS, Linux and Windows
and still look "native" - it is usually a good idea to keep the
default appearance of
most elements. Also one must accept that guis aren't as flexible as
html/css.
The upside is that using standard elements work with custom themes used
in the OS. Screen readers for blind also work with standard elements.
Also when (strictly hypothetically of course) some OS changes buttons from
squares to circles, then nothing in your code needs changing.

However, here is where to look for different knobs to tweak:

Arranging
========

To place gui elements in a row:         use horizontal-pane%
or horizontal-panel%
To place gui elements in a column:   use vertical-pane%
 or vertical-panel%
Use panels if you need to respond to events.
These elements support alignments and borders.

For custom placement in a row, make a subclass of horizontal-panel%.
For custom placement in a column, make a subclass of vertical-panel%.
For custom placement in a 2d-area, make a subclass of panel%.

Use vertical-pane% for left alignment.

Study:   https://docs.racket-lang.org/gui/Windowing_Classes.html?q=gui

Borders
======
For system borders use the a some kind of pane/panel to put your element in.
Then turn on the border of the pane/panel. You can also add padding by
putting an element inside a pane/panel.

Custom borders are tricky.

Canvas
======
For a canvas you have full control over colors and contents - but the
downside
is that you need to draw everything yourself.

Basic Elements
============
The most basic elements: mesages (labels),  buttons, check boxes, sliders
etc
are here:

https://docs.racket-lang.org/gui/control___.html?q=gui


Compound Elements / OS Elements
============================
>From the basic elements one can build more complicated elements.
Look around in the documentation for these. If you can't find
an element ask around - chances are that you are not the first
to need a certain type of element.

Some OS level elements such as "pick a file" dialogs finder:put-file and
finder:get-file  are found in `framework` (not in `racket/gui`).


General Advice
============
The gui system uses classes and objects. If you need to change the
behaviour of certain elements, say, a button. One must make a
subclass, say, my-button%, that overrides/replaces the default
behaviour. Then that class must be instantiated.

Look in the 7gui repo for examples of this.

Blogs
====
Alex Harsányi has written many blog posts on how to use the Racket gui.
https://racket-stories.com/from/327

Other gui related blog posts:
https://racket-stories.com/from/248

Video in Racket guis:
https://www.youtube.com/watch?v=yo6wVXS6dkU

/Jens Axel

-- 
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/CABefVgy97vqaH4uaxTs0qHBJB0k0q00XTSMYho2ijmCB3Jd4eQ%40mail.gmail.com.

Reply via email to