3.3.3 Panels
3.3.3.1 HPanel
3.3.3.2 VPanel
3.3.3.3 Group  Panel
3.3.3.4 Tab  Panel
On this page:
Tab  Panel
Tab  Panel.at_  selection
Tab  Panel.Style
Tab  Panel.Style.no_  border
Tab  Panel.Style.can_  reorder
Tab  Panel.Style.can_  close
Tab  Panel.Style.new_  button
Tab  Panel.Style.flat_  portable
Tab  Panel.Action
Tab  Panel.Action.select
Tab  Panel.Action.new
Tab  Panel.Action.close
Tab  Panel.Action.reorder

image   image

class

class gui.TabPanel():

  implements WindowChildView

  constructor (

    choices :: ObsOrValue.of(List),

    ~selection: selection :: ObsOrValue.of(Any),

    ~action: action :: (TabPanel.Action, List, maybe(Any)) -> ~any = values,

    ~choice_to_label: choice_to_label :: Any -> Any = values,

    ~choice_equal: choice_equal :: Function.of_arity(2) = (_ == _),

    ~style: style :: ObsOrValue.of(List.of(TabPanel.Style)) = [],

    ~align: align :: ObsOrValue.of(View.Alignment) = [#'center, #'center],

    ~spacing: spacing :: ObsOrValue.of(View.SpacingInt) = 0,

    ~margin: margin :: ObsOrValue.of(View.Margin) = [0, 0],

    ~min_size: min_size :: ObsOrValue.of(View.Size) = [#false, #false],

    ~stretch: stretch :: ObsOrValue.of(View.Stretch) = [#true, #true],

    ~enable: enable :: ObsOrValue.of(Boolean) = #true,

    ~window_callbacks: window_callbacks :: maybe(WindowCallbacks) = #false,

    child :: ObsOrValue.of(WindowChildView && !WindowView),

    ...

  )

 

property

property (tabs :: gui.TabPanel).at_selection :: Obs

Creates a tab panel where choices provides the number and identity of choices, and selection determines which of the tabs is selected.

The choice_to_label function converts an item in choices to a label to be shown for the tab, and choice_equal defines equality for choice identities. By default, choices is expected to be a list of View.LabelString, since choice_to_label is the identity function.

The TabPanel.at_selection property returns an observable that is updated whenever the panel changes through an action (as also reported via action) or via selection as an observable. To change the content of a TabPanel based on its selection, supply a child that is an observable derived from the TabPanel.at_selection property.

When the tab selection changes, action is called as

action(what, choices, selected)

where what describes the action, choices is the list of choices at the time of the action, and selected is the tab (if any) selected after the action.

See Geometry Management for information about ~align, ~spacing, ~margin, ~min_size, and ~stretch.

When a panel is disabled via ~enable, all content within the panel is also disabled.

The ~window_callbacks argument configures callbacks that are common to all WindowChildViews. See WindowCallbacks for more information.

A tab panel style option.

  • #'no_border: No border is drawn around the panel content. A borderless tab panel typically has a different look for its tabs, too.

  • #'can_reorder: Allows the user to reorder tabs by dragging them.

  • #'can_close: Allows the user to close tabs by clicking a close icon on a tab.

  • #'new_button: Include a button to create a new tab, if supported. A tab-creation button is always available with #'flat_portable.

  • #'flat_portable: Use a platform-independent implementation of the tab control, which provides more consistent functionality and style across platforms.

enumeration

enum gui.TabPanel.Action

| select

| new

| close

| reorder

A tab panel action provided to the ~action callback function of a Panel.