Widgets

As a project that has focused more on the capabilities of cross-platform graphical rendering on the lower layer, Shiny toolkit does not come with many standard widgets. A lot of work has gone in to setting up the building blocks so that applications can provide their own widgets, but if you are looking to use built-in types, the list provided by the widget package is as follows:

  • Flow: This is a container that lays out its children along a horizontal or vertical axis (set in Flow.Axis or NewFlow()).
  • Flex: Actually, in a flex sub-package, this is a container that lays out its children according to the CSS flexbox algorithm. As with widget.Flowthe parameters for the layout are set on the flex.Flex container.
  • Image: This widget renders a golang image.Image onscreen. Its dimensions are specified separately to the image.
  • Label: This is a simple widget for displaying a line of text with a theme color (for example, theme.Foreground).
  • Padder: An invisible widget that contains a child widget and displays it with a specified amount of space around the horizontal or vertical dimensions (or both).
  • Sheet: A sheet provides the buffer on which all other widgets will draw. Any widgets that are not children of a Sheet may not be rendered. Multiple sheets are required if content should move independently, such as a scroll view.
  • Sizer: A sizer is an invisible widget that contains a child widget but overrides its size. This can be used to specify a different natural size than the default for an existing widget.
  • Space: An invisible widget that takes up available space. Placed between two widgets, they will become left- and right- aligned, or by placing  widget.Space either side of a widget, it will become centered.
  • Text: A multi-line text widget for displaying more complicated text than widget.Label.
  • Uniform: This is a simple widget that draws a rectangle of a solid color from the theme palette (for example, theme.Background).

There is also an advanced widget named glwidget.GL, which renders a OpenGL for embedded systems (GLES) framebuffer into a Shiny application. This is not commonly required for traditional applications but it's a great additional feature to support.

Despite the length of the preceding list, you'll probably notice that it does not provide all the widgets we have used in other chapters. For this reason, we will build a different sample application. This time, one that's a better fit for the toolkit's capabilities. Before that, however, let's return to getting started and creating a hello world application.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.156.251