Module reahl.web.bootstrap.navs

New in version 3.2.

A Bootstrap “Nav” is a navigation menu: a list of items that are links to other Views. Navs can also have a second level so that if you click on an item, a dropdown list of vertically stacked options appear.

This module contains the necessary Widgets and Layouts to create and style Bootstrap Navs.

Changed in version 4.0: Moved Menu here from reahl.web.ui.

Changed in version 4.0: Removed the .add_item and add_submenu methods in favour of .add_a,.add_bookmark,.add_dropdown methods.

' Copyright 2017, 2018 Reahl Software Services (Pty) Ltd. All rights reserved.

@startuml
!include ../../../../base.iuml

title Menus and Layout

class A #grey
class Layout #grey
class HTMLWidget #grey
class HTMLElement #grey

HTMLWidget -right- HTMLElement : html_representation

HTMLWidget <|-- Menu
Menu <|-- DropDownMenu
Menu <|-- Nav
Menu -right- Layout
Menu -left- "*" MenuItem
MenuItem -up- A

Layout <|-- NavLayout
Layout <|-- DropDownMenuLayout
NavLayout <|-- PillLayout
NavLayout <|-- TabLayout

note " #grey items are Core,\n others are Bootstrap" as N1

@enduml

PillLayout

class reahl.web.bootstrap.navs.PillLayout(stacked=False, content_alignment=None, content_justification=None)

This Layout makes a Nav appear as horizontally or vertically arranged pills (buttons).

Parameters
  • stacked – If True, the pills are stacked vertically.

  • content_alignment – If given, changes how content is aligned inside the Nav (default is start) (One of: center, end)

  • content_justification – If given, makes the content take up all space in the Nav. Either with elements having equal space (fill), or unequal space (justified) (One of: fill, justified)

customise_widget()

Override this method in subclasses to allow your Layout to change its Widget upon construction. There is no need to call super(), as the superclass implementation does nothing.

TabLayout

class reahl.web.bootstrap.navs.TabLayout(content_alignment=None, content_justification=None)

This Layout makes a Nav appear as horizontal tabs.

Parameters
  • content_alignment – If given, changes how content is aligned inside the Nav (default is start) (One of: center, end)

  • content_justification – If given, makes the content take up all space in the Nav. Either with elements having equal space (fill), or unequal space (justified) (One of: fill, justified)