Anchor(inner=None)
Name | Type | Description |
---|---|---|
inner |
str|WebComponent
|
The object wrapped by the anchor. |
The
Anchor
component is used for creating a hyperlink to pages, files,
email addresses, locations on the same page, or other web-resources
defined by a URL address. The
Bootwrap
also uses the
Anchor
in
conjunction with other components, for example, in creating a navigation
menu.
from bootwrap import Anchor
Anchor('Google Search').link('https://www.google.com/')
Change
Anchor
appearance using the following functions
as_primary()
,
as_secondary()
,
as_success()
,
as_warning()
,
as_danger()
,
as_info()
,
as_light()
, and
as_dark()
.
from bootwrap import Panel, Anchor
panel = Panel(
Anchor("Primary").link("#").as_primary(),
Anchor("Secondary").link("#").as_secondary(),
Anchor("Success").link("#").as_success(),
Anchor("Warning").link("#").as_warning(),
Anchor("Danger").link("#").as_danger(),
Anchor("Info").link("#").as_info(),
Anchor("Light").link("#").as_light(),
Anchor("Dark").link("#").as_dark()
)
for anchor in panel:
anchor.mb(1)
panel
Associate
Anchor
with a hyperlink using the
link()
function.
from bootwrap import Panel, Anchor
Panel(
Anchor("Google Search").link("https://www.google.com/")
)
Use
Anchor
to open a dialog using the
toggle()
function.
from bootwrap import Panel, Dialog, Anchor
dialog = Dialog(
"Greeting",
"Hello World!"
)
anchor = Anchor("Say Hello").toggle(dialog)
Panel(dialog, anchor)
Use
Anchor
to close a dialog using the
dismiss()
function.
from bootwrap import Panel, Dialog, Anchor
dialog = Dialog(
"Greeting",
"Hello World!",
Anchor("Bye").dismiss()
)
anchor = Anchor("Say Hello").toggle(dialog)
Panel(dialog, anchor)
Use
Anchor
to expand/collapse a panel using the
toggle()
function.
from bootwrap import Panel, Anchor
quote = Panel(
"Sometimes life is going to hit you in " +
"the head with a brick. Don’t lose faith."
).as_collapse()
Panel(
Anchor("Steve Jobs Quote").toggle(quote),
quote
)
Badge(label)
Name | Type | Description |
---|---|---|
label |
str
|
The badge label (text showing inside a badge). |
from bootwrap import Badge
Badge('Some Badge').as_dark()
Change
Badge
appearance using the following functions
as_primary()
,
as_secondary()
,
as_success()
,
as_warning()
,
as_danger()
,
as_info()
,
as_light()
, and
as_dark()
.
from bootwrap import Panel, Badge
panel = Panel(
Badge("Primary").as_primary(),
Badge("Secondary").as_secondary(),
Badge("Success").as_success(),
Badge("Warning").as_warning(),
Badge("Danger").as_danger(),
Badge("Info").as_info(),
Badge("Light").as_light(),
Badge("Dark").as_dark()
)
for anchor in panel:
anchor.mb(1)
panel
Button(name)
Name | Type | Description |
---|---|---|
name |
str
|
The button name. |
Without applying a stylized method
Button
will be appearing very
similar to the
Anchor
.
from bootwrap import Button
Button('Google Search').link('https://www.google.com/')
with_icon(icon, right_side=False)
Name | Type | Description |
---|---|---|
icon |
Icon
|
The icon to add on button. |
right_side |
bool
|
If
True
the icon is placed on the right side of the button
name and
False
on the right side accordingly.
|
from bootwrap import Button, Icon, Panel
ico_left = Icon("fa-solid fa-arrow-left")
btn_left = Button("Left").with_icon(ico_left).as_primary()
ico_right = Icon("fa-solid fa-arrow-right")
btn_right = Button("Right").with_icon(ico_right, True).as_primary()
Panel(btn_left, btn_right)
Change
Button
appearance using the following functions
as_primary()
,
as_secondary()
,
as_success()
,
as_warning()
,
as_danger()
,
as_info()
,
as_light()
, and
as_dark()
.
from bootwrap import Panel, Button
panel = Panel(
Button("Primary").link("#").as_primary(),
Button("Secondary").link("#").as_secondary(),
Button("Success").link("#").as_success(),
Button("Warning").link("#").as_warning(),
Button("Danger").link("#").as_danger(),
Button("Info").link("#").as_info(),
Button("Light").link("#").as_light(),
Button("Dark").link("#").as_dark()
)
for anchor in panel:
anchor.mb(1)
panel
Make
Button
without filling with surrounded by color border using the following function
as primary()
.
from bootwrap import Panel, Button
panel = Panel(
Button("Primary").link("#").as_primary().as_outline(),
Button("Secondary").link("#").as_secondary().as_outline(),
Button("Success").link("#").as_success().as_outline(),
Button("Warning").link("#").as_warning().as_outline(),
Button("Danger").link("#").as_danger().as_outline(),
Button("Info").link("#").as_info().as_outline(),
Button("Light").link("#").as_light().as_outline(),
Button("Dark").link("#").as_dark().as_outline()
)
for anchor in panel:
anchor.mb(1)
panel
But default the
Button
always enabled. Use the
as_disabled()
function to make the
Button
disabled. Disable status prevent user to initiate any action assigned to the
Button
.
from bootwrap import Panel, Button
Panel(
Button("Enabled").as_primary(),
Button("Disabled").as_primary().as_disabled()
)
Associate
Button
with a hyperlink using the
link()
function.
from bootwrap import Panel, Button
Panel(
Button("Google Search").as_primary().link("https://www.google.com/")
)
Use
Button
to open a dialog using the
toggle()
function.
from bootwrap import Panel, Dialog, Button
dialog = Dialog(
"Greeting",
"Hello World!"
)
button = Button("Say Hello").as_primary().toggle(dialog)
Panel(dialog, button)
Use
Button
to close a dialog using the
dismiss()
function.
from bootwrap import Panel, Dialog, Button
dialog = Dialog(
"Greeting",
"Hello World!",
Button("Bye").as_primary().dismiss()
)
button = Button("Say Hello").as_primary().toggle(dialog)
Panel(dialog, button)
Use
Button
to expand/collapse a panel using the
toggle()
function.
from bootwrap import Panel, Button
quote = Panel(
"Sometimes life is going to hit you in " +
"the head with a brick. Don’t lose faith."
).as_collapse()
Panel(
Button("Steve Jobs Quote").as_primary().toggle(quote),
quote
)
Use
Button
to submit form content using the
submit()
function.
Note:
to make a form submit do not forget to use the
Form
function
on_submit()
, which specifies a URL that handles the post request. For more information view the
Form
documentation.
from bootwrap import Form, TextInput, Button
Form(
TextInput("Email", "email", "my@email.com").for_email(),
Button("Send").as_primary().submit()
)
ButtonGroup(*buttons)
Name | Type | Description |
---|---|---|
*buttons |
list
|
The list of
WebComponent
.
|
Group a series of buttons together on a single line or stack them in a vertical column.
from bootwrap import Button, ButtonGroup
button1 = Button('One').as_success()
button2 = Button('Two').as_warning()
button3 = Button('Three').as_danger()
ButtonGroup(button1, button2, button3)
Group a series of buttons together, which act as check boxes.
from bootwrap import CheckboxInput, ButtonGroup
button1 = CheckboxInput('One', 'opt1').as_button().as_secondary()
button2 = CheckboxInput('Two', 'opt2').as_button().as_secondary()
button3 = CheckboxInput('Three', 'opt3').as_button().as_secondary()
ButtonGroup(button1, button2, button3)
Group a series of buttons together, which act as radio buttons.
from bootwrap import CheckboxInput, ButtonGroup
button1 = CheckboxInput('One', 'opt').as_radio(1).as_button().as_secondary()
button2 = CheckboxInput('Two', 'opt').as_radio(2).as_button().as_secondary()
button3 = CheckboxInput('Three', 'opt').as_radio(3).as_button().as_secondary()
ButtonGroup(button1, button2, button3)
Deck(*cards)
Name | Type | Description |
---|---|---|
*cards |
list
|
The
list
of
Deck.Card
elements.
|
from bootwrap import Button, Deck, Image
actions = [
Button("Buy"),
Button("Sell"),
Button("Transfer")
]
Deck(
Deck.Card(
"Google (NASDAQ: GOOGL)",
description= "Price for a single Google share",
figure=Image("google-logo.png", width=128).mt(3),
marker="12:04:58 12/01/2021"
).add_menu(*actions).pack_actions().link(
"https://www.google.com"),
Deck.Card(
"LinkedIn (NASDAQ: LNKD)",
description= "Price for a single LinkedIn share",
figure=Image("linkedin-logo.png", width=128).mt(3),
marker="12:04:58 12/01/2021"
).add_menu(*actions).pack_actions().link(
"https://www.linkedin.com"),
Deck.Card(
"Amazon (NASDAQ: AMZN)",
description= "Price for a single Amazon share",
figure=Image("amazon-logo.png", width=128).mt(3),
marker="12:04:58 12/01/2021"
).add_menu(*actions).pack_actions().link(
"https://www.amazon.com")
)
Deck.Card(title, description=None, marker=None, figure=None)
Name | Type | Description |
---|---|---|
title |
str|WebComponent
|
The card title. |
description |
str|WebComponent
|
The card description. |
marker |
str|WebComponent
|
The card marker. |
figure |
str|WebComponent
|
The card figure. |
from bootwrap import Button, Deck, Image
actions = [
Button("Buy"),
Button("Sell"),
Button("Transfer")
]
Deck.Card(
"Google (NASDAQ: GOOGL)",
description= "Price for a single Google share",
figure=Image("google-logo.png", width=128).mt(3),
marker="12:04:58 12/01/2021"
).add_menu(*actions).link(
"https://www.google.com")
pack_actions()
from bootwrap import Button, Deck, Image
actions = [
Button("Buy"),
Button("Sell"),
Button("Transfer")
]
Deck.Card(
"Google (NASDAQ: GOOGL)",
description= "Price for a single Google share",
figure=Image("google-logo.png", width=128).mt(3),
marker="12:04:58 12/01/2021"
).add_menu(*actions).pack_actions().link(
"https://www.google.com")
Dialog(title, content, *actions)
Name | Type | Description |
---|---|---|
title |
str
|
The dialog title. |
content |
str|WebComponent
|
The content inside a dialog window to show. |
*actions |
list
|
The dialog actions. |
from bootwrap import Panel, Dialog, Button
dialog = Dialog(
'Greeting',
'Hello World!',
Button('Bye').dismiss()
)
button = Button('Say Hello').toggle(dialog)
Panel(dialog, button)
An example of how
Dialog
can be used for confirming a specific action. Make sure that you provide a correct URL, which
Confirm
Button
linked to. You can specify define this URL something like this
local/file_system?file_id=1234567&action=delete
from bootwrap import Panel, Dialog, Button
dialog = Dialog(
"Delete File",
"Are you sure that you want to delete this file?",
Button("Confirm").as_danger().dismiss(),
Button("Cancel").dismiss()
).as_danger()
button = Button("Delete").as_danger().toggle(dialog)
Panel(dialog, button)
An example of how
Dialog
can be used for buying shares. It contains a web
Form
where a user can specify an amount (in Dollars) for buying shares. When the user presses the
Buy
Button
, the form will be submitted to the server (at
url/to/act
). If the user selects
Cancel
, the dialog will be closed, discarding the buying action.
from bootwrap import Panel, Form, NumericInput, Dialog, Button
dialog = Dialog(
"Buy Company Shares",
Form(
NumericInput(
"Amount($)",
"amount",
placeholder="enter an amount for buying shares"
),
Button("Cancel").add_classes("float-right").dismiss(),
Button("Buy").add_classes("float-right").me(2).as_success().
dismiss()
)
)
button = Button("Buy Shares").as_primary().toggle(dialog)
Panel(dialog, button)
Form(*components)
Name | Type | Description |
---|---|---|
*components |
list
|
The list of
WebComponent
representing form
elements for input and action.
|
Use the
on_submit(href)
function to specify URL where entered
information should to be sent for processing.
from bootwrap import Form
Form(
# here should be an enumeration of
# input components and actions
...
).on_submit('go/to/this/url')
on_submit(href)
Name | Type | Description |
---|---|---|
href |
str
|
The URL for submitting the form. |
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Form
Form(...).on_submit('go/to/this/url')
CheckboxInput(label, name, checked=False)
Name | Type | Description |
---|---|---|
label |
str
|
The input label. |
name |
str
|
The input name. |
checked |
bool
|
The check box status. |
Use the
as_disabled()
function to prevent the user from changing
status of the
CheckboxInput
component.
from bootwrap import Form, CheckboxInput
Form(
CheckboxInput('One', 'opt1'),
CheckboxInput('Two', 'opt2', True),
CheckboxInput('Three', 'opt3').as_disabled(),
CheckboxInput('Four', 'opt4', True).as_disabled()
)
as_button()
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Form, CheckboxInput
Form(
CheckboxInput('One', 'opt1').as_button().as_primary().as_outline(),
CheckboxInput('Two', 'opt2', True).as_button(),
CheckboxInput('Three', 'opt3').as_button().as_disabled(),
CheckboxInput('Four', 'opt4', True).as_button().as_disabled()
)
as_radio(value)
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Form, CheckboxInput
Form(
CheckboxInput('One', 'opt').as_radio(1),
CheckboxInput('Two', 'opt', True).as_radio(2),
CheckboxInput('Three', 'opt').as_radio(3).as_disabled(),
CheckboxInput('Four', 'opt', True).as_radio(4).as_disabled()
)
as_switch()
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Form, CheckboxInput
Form(
CheckboxInput('One', 'opt1').as_switch(),
CheckboxInput('Two', 'opt2', True).as_switch(),
CheckboxInput('Three', 'opt3').as_switch().as_disabled(),
CheckboxInput('Four', 'opt4', True).as_switch().as_disabled()
)
inline()
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Form, CheckboxInput
Form(
CheckboxInput('One', 'opt1').inline(),
CheckboxInput('Two', 'opt2', True).inline(),
CheckboxInput('Three', 'opt3').inline().as_disabled(),
CheckboxInput('Four', 'opt4', True).inline().as_disabled()
)
label_on_left()
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Form, CheckboxInput
Form(
CheckboxInput('One', 'opt1').label_on_left(),
CheckboxInput('Two', 'opt2', True).label_on_left().as_switch(),
CheckboxInput('Three', 'opt3').label_on_left().as_disabled(),
CheckboxInput('Four', 'opt4', True).label_on_left().as_disabled()
)
TextInput(label, name, value=None, placeholder=None)
Name | Type | Description |
---|---|---|
label |
str
|
The input label |
name |
str
|
The input name. |
value |
str
|
The input value. |
placeholder |
str
|
The input placeholder. |
Use the
as_disabled()
function to prevent the user from entering data
to the
TextInput
component.
from bootwrap import Form, TextInput
Form(
TextInput('Text1', 'text'),
TextInput('Text2', 'text', placeholder='type here'),
TextInput('Text3', 'text', 'Hello World!'),
TextInput('Text4', 'text').as_disabled()
)
for_email()
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Form, TextInput
Form(
TextInput('Email', 'email', 'my@email.com').for_email()
)
for_password()
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Form, TextInput
Form(
TextInput('Password', 'password', '********').for_password()
)
with_multirows(n)
Name | Type | Description |
---|---|---|
n |
int
|
The number of rows to set. |
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Form, TextInput
Form(
TextInput('Text', 'text').with_multirows(3)
)
NumericInput(label, name, value=None, placeholder=None)
Name | Type | Description |
---|---|---|
label |
str
|
The input label |
name |
str
|
The input name. |
value |
obj
|
The input value. |
placeholder |
str
|
The input placeholder. |
Use the
as_disabled()
function to prevent the user from entering data
to the
NumericInput
component.
from bootwrap import Form, NumericInput
Form(
NumericInput('Number1', 'number'),
NumericInput('Number2', 'number', placeholder='type here'),
NumericInput('Number3', 'number', 123),
NumericInput('Number4', 'number').as_disabled()
)
SelectInput(label, name, value=None, options=None)
Name | Type | Description |
---|---|---|
label |
str
|
The input label |
name |
str
|
The input name. |
value |
str
|
The input value. |
options |
tuple
|
The input options. |
Use the
as_disabled()
function to prevent the user from entering data
to the
SelectInput
component.
from bootwrap import Form, SelectInput
options = [
SelectInput.Option('One', 1),
SelectInput.Option('Two', 2),
SelectInput.Option('Three', 3, disabled=True)
]
Form(
SelectInput('Selector1', 'choice', 2, options),
SelectInput('Selector2', 'choice', 2, options).as_disabled()
)
as_radio()
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Form, SelectInput
options = [
SelectInput.Option('One', 1),
SelectInput.Option('Two', 2),
SelectInput.Option('Three', 3, disabled=True)
]
Form(
SelectInput('Selector', 'choice', 2, options).as_radio()
)
SelectInput
.
SelectInput.Option(name, value, disabled=False)
Name | Type | Description |
---|---|---|
name |
str
|
The option name. |
value |
str
|
The option value value. |
disabled |
bool
|
True
makes the option disabled (in other words
user will not be able to choose this option).
|
JsonInput(label, name, value=None)
Name | Type | Description |
---|---|---|
label |
str
|
The input label |
name |
str
|
The input name. |
value |
str
|
The input value. |
from bootwrap import Form, JsonInput
Form(
JsonInput('JSON Config', 'code', '{"hello": "world enable"}'),
JsonInput('JSON Config', 'code', '{"hello": "world disable"}').as_disabled()
)
HiddenInput(name, value=None)
Name | Type | Description |
---|---|---|
name |
str
|
The input name. |
value |
obj
|
The input value. |
from bootwrap import Form, SelectInput
Form(
HiddenInput('token', '123')
)
FileInput(label, name)
Name | Type | Description |
---|---|---|
label |
str
|
The input label |
name |
str
|
The input name. |
Use the
as_disabled()
function to prevent the user from entering data
to the
FileInput
component.
from bootwrap import Form, FileInput
Form(
FileInput('File', 'file'),
FileInput('File', 'file').as_disabled()
)
InputGroup(*inputs)
Name | Type | Description |
---|---|---|
*components |
list
|
The list of
WebComponent
.
|
Grous together a series of input components
from bootwrap import Text, TextInput, NumericInput, InputGroup, Form
at = Text("@")
username = TextInput(None, 'username', placeholder='type username')
ig1 = InputGroup(at, username).mb(2)
recipient = TextInput(None, 'recipient', placeholder='Recipient username')
domain = Text("@example.com")
ig2 = InputGroup(recipient, domain).mb(2)
recipient = TextInput(None, 'recipient', placeholder='Recipient username')
domain = Text("@example.com")
ig2 = InputGroup(recipient, domain).mb(2)
money = Text("$")
amount = NumericInput(None, 'amount', placeholder='Amount (to the nearest dollar)')
cents = Text(".00")
ig3 = InputGroup(money, amount, cents).mb(2)
login = TextInput(None, 'login', placeholder='Login')
at = Text("@")
password = TextInput(None, 'password', placeholder='Password').for_password()
ig4 = InputGroup(login, at, password).mb(2)
Form(ig1,ig2,ig3,ig4)
Icon(name)
Name | Type | Description |
---|---|---|
name |
str
|
The icon name. |
from bootwrap import Icon, Panel
Panel(
Icon("fas fa-folder"),
Icon("fas fa-folder").as_primary(),
Icon("fas fa-folder").as_secondary(),
Icon("fas fa-folder").as_success(),
Icon("fas fa-folder").as_warning(),
Icon("fas fa-folder").as_danger(),
Icon("fas fa-folder").as_info(),
Icon("fas fa-folder").as_light(),
Icon("fas fa-folder").as_dark()
)
Spinner()
from bootwrap import Spinner, Panel
Panel(
Spinner(),
Spinner().as_primary(),
Spinner().as_secondary(),
Spinner().as_success(),
Spinner().as_warning(),
Spinner().as_danger(),
Spinner().as_info(),
Spinner().as_light(),
Spinner().as_dark()
)
Image(src, width=None, height=None, alt=None)
Name | Type | Description |
---|---|---|
src |
obj
|
The image source to show. |
width |
int
|
The image width. |
height |
int
|
The image height. |
alt |
str
|
The alt text. |
from bootwrap import Image
Image("logo.png")
Javascript(src=None, script=None, submap=None)
Name | Type | Description |
---|---|---|
src |
str
|
The URL to load javascript. A URL can be absolute or relative. |
script |
str
|
The javascript code. |
submap |
dict
|
The map with substitutions, binding the javascript with Python objects. |
from bootwrap import Page, Javascript
my_page = Page(
...
resources = [
Javascript("https://ajax...0/jquery.min.js")
]
...
)
Use
Javascript
for creating interactive web content with the help of jQuery.
from bootwrap import Panel, Javascript, Button, Text
label = Text("Answer:").as_strong()
answer = Text("unknown").me(2).ms(2)
btn_yes = Button("Yes").as_success()
btn_no = Button("No").as_danger()
action = Javascript(
script='''
$("#btn_yes").on("click",function(){
$("#answer").text("Yes");
});
$("#btn_no").on("click",function(){
$("#answer").text("No");
});
''',
submap={
"answer": answer,
"btn_yes": btn_yes,
"btn_no": btn_no
}
)
Panel(
label, answer, btn_yes, btn_no, action
)
Link(href, rel='stylesheet', ctype='text/css')
Name | Type | Description |
---|---|---|
href |
str
|
This attribute specifies the URL of the linked resource. A URL can be absolute or relative (from MDN WebDoc). |
rel |
str
|
This attribute names a relationship of the linked document to the current document (from MDN WebDoc). |
ctype |
str
|
This attribute is used to define the type of the content linked to (from MDN WebDoc). |
See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link for more information.
from bootwrap import Page, Link
my_page = Page(
...
resources = [
Link("https://cdnjs.cloudflare.com/.../all.min.css")
]
...
)
List(*items)
Name | Type | Description |
---|---|---|
*items |
list
|
The
list
of
List.Item
elements.
|
from bootwrap import Button, List, Image
actions = [
Button("Buy").as_success(),
Button("Sell"),
Button("Transfer")
]
List(
List.Item(
"Google (NASDAQ: GOOGL)",
description= "Price for a single Google share",
figure=Image("google-logo.png", width=32, height=32),
marker="12:04:58 12/01/2021"
).add_menu(*actions).pack_actions().as_selected().link(
"https://www.google.com"),
List.Item(
"LinkedIn (NASDAQ: LNKD)",
description= "Price for a single LinkedIn share",
figure=Image("linkedin-logo.png", width=32, height=32),
marker="12:04:58 12/01/2021"
).add_menu(*actions).pack_actions().link(
"https://www.linkedin.com"),
List.Item(
"Amazon (NASDAQ: AMZN)",
description= "Price for a single Amazon share",
figure=Image("amazon-logo.png", width=32, height=32),
marker="12:04:58 12/01/2021"
).add_menu(*actions).pack_actions().link(
"https://www.amazon.com")
)
List.Item(title, description=None, marker=None, figure=None)
Name | Type | Description |
---|---|---|
title |
str|WebComponent
|
The item title. |
description |
str|WebComponent
|
The item description. |
marker |
str|WebComponent
|
The item marker. |
figure |
str|WebComponent
|
The item figure. |
from bootwrap import Button, List, Image
actions = [
Button("Buy"),
Button("Sell"),
Button("Transfer")
]
List(
List.Item(
"Google (NASDAQ: GOOGL)",
description= "Price for a single Google share",
figure=Image("google-logo.png", width=32, height=32),
marker="12:04:58 12/01/2021"
).add_menu(*actions).link("https://www.google.com")
)
as_selected()
from bootwrap import Button, List, Image
actions = [
Button("Buy"),
Button("Sell"),
Button("Transfer")
]
List(
List.Item(
"Google (NASDAQ: GOOGL)",
description= "Price for a single Google share",
figure=Image("google-logo.png", width=32, height=32),
marker="12:04:58 12/01/2021"
).add_menu(*actions).as_selected().link(
"https://www.google.com")
)
pack_actions()
from bootwrap import Button, List, Image
actions = [
Button("Buy"),
Button("Sell"),
Button("Transfer")
]
List(
List.Item(
"Google (NASDAQ: GOOGL)",
description= "Price for a single Google share",
figure=Image("google-logo.png", width=32, height=32),
marker="12:04:58 12/01/2021"
).add_menu(*actions).pack_actions().link(
"https://www.google.com")
)
Navigation(*items)
Name | Type | Description |
---|---|---|
*items |
list
|
The list of
Navigation.Item
.
|
from bootwrap import Navigation
Navigation(
Navigation.Item('Chapter 1', 'Text 1', True),
Navigation.Item('Chapter 2', 'Text 2'),
Navigation.Item('Chapter 3', 'Text 3')
)
as_pills()
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Navigation
Navigation(
Navigation.Item('Chapter 1', 'Text 1', True),
Navigation.Item('Chapter 2', 'Text 2'),
Navigation.Item('Chapter 3', 'Text 3')
).as_pills()
as_tabs()
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Navigation
Navigation(
Navigation.Item('Chapter 1', 'Text 1', True),
Navigation.Item('Chapter 2', 'Text 2'),
Navigation.Item('Chapter 3', 'Text 3')
).as_tabs()
as_vertical()
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Navigation
Navigation(
Navigation.Item('Chapter1', 'Text 1', True),
Navigation.Item('Chapter2', 'Text 2'),
Navigation.Item('Chapter3', 'Text 3')
).as_vertical().as_pills()
Navigation.Item(name, content, active=False)
Panel(*components)
Name | Type | Description |
---|---|---|
*components |
list
|
The list of
WebComponent
.
|
from bootwrap import Text, Panel
comp1 = Text("Component 1").as_outline().ms(1)
comp2 = Text("Component 2").as_outline().ms(1)
comp3 = Text("Component 3").as_outline().ms(1)
Panel(comp1, comp2, comp3)
align_items(style)
Name | Type | Description |
---|---|---|
style |
str
|
The style for aligning items can be one of "start", "end", "center", "baseline", "stretch". |
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Text, Panel, Image
image = Image("logo.png", height="200px")
comp1 = Text("Component 1").as_light().as_outline().p(2).m(2)
comp2 = Text("Component 2").as_light().as_outline().p(2).m(2)
comp3 = Text("Component 3").as_light().as_outline().p(2).m(2)
pnl_start = Panel(image, comp1, comp2, comp3).as_dark().align_items("start").mt(1)
pnl_end = Panel(image, comp1, comp2, comp3).as_dark().align_items("end").mt(1)
pnl_center = Panel(image, comp1, comp2, comp3).as_dark().align_items("center").mt(1)
pnl_baseline = Panel(image, comp1, comp2, comp3).as_dark().align_items("baseline").mt(1)
pnl_stretch = Panel(image, comp1, comp2, comp3).as_dark().align_items("stretch").mt(1)
Panel(
pnl_start,
pnl_end,
pnl_center,
pnl_baseline,
pnl_stretch,
).vertical()
as_collapse()
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
horizontal()
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Text, Panel
comp1 = Text("Component 1").as_outline()
comp2 = Text("Component 2").as_outline()
comp3 = Text("Component 3").as_outline()
Panel(comp1, comp2, comp3).horizontal()
justify_content(style)
Name | Type | Description |
---|---|---|
style |
str
|
The style for justifying content can be one of "start", "end", "center", "between", "around", "evenly". |
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Text, Panel
comp1 = Text("Component 1").as_light().as_outline().p(2).m(2)
comp2 = Text("Component 2").as_light().as_outline().p(2).m(2)
comp3 = Text("Component 3").as_light().as_outline().p(2).m(2)
pnl_start = Panel(comp1, comp2, comp3).as_dark().justify_content("start").mt(1)
pnl_end = Panel(comp1, comp2, comp3).as_dark().justify_content("end").mt(1)
pnl_center = Panel(comp1, comp2, comp3).as_dark().justify_content("center").mt(1)
pnl_between = Panel(comp1, comp2, comp3).as_dark().justify_content("between").mt(1)
pnl_around = Panel(comp1, comp2, comp3).as_dark().justify_content("around").mt(1)
pnl_evenly = Panel(comp1, comp2, comp3).as_dark().justify_content("evenly").mt(1)
Panel(
pnl_start,
pnl_end,
pnl_center,
pnl_between,
pnl_around,
pnl_evenly
).vertical()
vertical()
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Text, Panel
comp1 = Text("Component 1").as_outline()
comp2 = Text("Component 2").as_outline()
comp3 = Text("Component 3").as_outline()
Panel(comp1, comp2, comp3).vertical()
Change
Panel
appearance using the following functions
as_primary()
,
as_secondary()
,
as_success()
,
as_warning()
,
as_danger()
,
as_info()
,
as_light()
, and
as_dark()
.
from bootwrap import Panel, Text
panel = Panel(
Panel(Text("Primary")).as_primary(),
Panel(Text("Secondary")).as_secondary(),
Panel(Text("Success")).as_success(),
Panel(Text("Warning")).as_warning(),
Panel(Text("Danger")).as_danger(),
Panel(Text("Info")).as_info(),
Panel(Text("Light")).as_light(),
Panel(Text("Dark").as_light()).as_dark()
)
for anchor in panel:
anchor.mb(1)
panel
Make
Panel
without filling with surrounded by color border using the following function
as_outline()
.
from bootwrap import Panel, Text
panel = Panel(
Panel(Text("Primary").as_primary()).as_primary().as_outline(),
Panel(Text("Secondary").as_secondary()).as_secondary().as_outline(),
Panel(Text("Success").as_success()).as_success().as_outline(),
Panel(Text("Warning").as_warning()).as_warning().as_outline(),
Panel(Text("Danger").as_danger()).as_danger().as_outline(),
Panel(Text("Info").as_info()).as_info().as_outline(),
Panel(Text("Light").as_light()).as_light().as_outline(),
Panel(Text("Dark").as_dark()).as_dark().as_outline()
)
for anchor in panel:
anchor.mb(1)
panel
Separator()
from bootwrap import Panel, Separator, Text
Panel(
Text("Top Text"),
Separator(),
Text("Bottom Text")
)
Table(head, body)
Name | Type | Description |
---|---|---|
head |
list
|
The table head (1D array). |
body |
list
|
The table body (2D array). |
from bootwrap import Table
Table(
["Column 1", "Column 2", "Column 3"],
[
["Value 11", "Value 12", "Value 13"],
["Value 21", "Value 22", "Value 23"],
["Value 31", "Value 32", "Value 33"],
]
)
Column 1 | Column 2 | Column 3 |
---|---|---|
Value 11 | Value 12 | Value 13 |
Value 21 | Value 22 | Value 23 |
Value 31 | Value 32 | Value 33 |
as_bordered()
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Table
Table(
["Column 1", "Column 2", "Column 3"],
[
["Value 11", "Value 12", "Value 13"],
["Value 21", "Value 22", "Value 23"],
["Value 31", "Value 32", "Value 33"],
]
).as_bordered()
Column 1 | Column 2 | Column 3 |
---|---|---|
Value 11 | Value 12 | Value 13 |
Value 21 | Value 22 | Value 23 |
Value 31 | Value 32 | Value 33 |
as_dark()
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Table
Table(
["Column 1", "Column 2", "Column 3"],
[
["Value 11", "Value 12", "Value 13"],
["Value 21", "Value 22", "Value 23"],
["Value 31", "Value 32", "Value 33"],
]
).as_dark()
Column 1 | Column 2 | Column 3 |
---|---|---|
Value 11 | Value 12 | Value 13 |
Value 21 | Value 22 | Value 23 |
Value 31 | Value 32 | Value 33 |
as_responsive(breakpoint=)
Name | Type | Description |
---|---|---|
breakpoint |
str
|
The breakpoint to apply. |
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Table
Table(
["Column 1", "Column 2", "Column 3"],
[
["Value 11", "Value 12", "Value 13"],
["Value 21", "Value 22", "Value 23"],
["Value 31", "Value 32", "Value 33"],
]
).as_responsive()
Column 1 | Column 2 | Column 3 |
---|---|---|
Value 11 | Value 12 | Value 13 |
Value 21 | Value 22 | Value 23 |
Value 31 | Value 32 | Value 33 |
as_small()
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Table
Table(
["Column 1", "Column 2", "Column 3"],
[
["Value 11", "Value 12", "Value 13"],
["Value 21", "Value 22", "Value 23"],
["Value 31", "Value 32", "Value 33"],
]
).as_small()
Column 1 | Column 2 | Column 3 |
---|---|---|
Value 11 | Value 12 | Value 13 |
Value 21 | Value 22 | Value 23 |
Value 31 | Value 32 | Value 33 |
as_striped()
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Table
Table(
["Column 1", "Column 2", "Column 3"],
[
["Value 11", "Value 12", "Value 13"],
["Value 21", "Value 22", "Value 23"],
["Value 31", "Value 32", "Value 33"],
]
).as_striped()
Column 1 | Column 2 | Column 3 |
---|---|---|
Value 11 | Value 12 | Value 13 |
Value 21 | Value 22 | Value 23 |
Value 31 | Value 32 | Value 33 |
Table.Head(head)
as_dark()
from bootwrap import Table
table = Table(
["Column 1", "Column 2", "Column 3"],
[
["Value 11", "Value 12", "Value 13"],
["Value 21", "Value 22", "Value 23"],
["Value 31", "Value 32", "Value 33"],
]
)
table.head.as_dark()
table
Column 1 | Column 2 | Column 3 |
---|---|---|
Value 11 | Value 12 | Value 13 |
Value 21 | Value 22 | Value 23 |
Value 31 | Value 32 | Value 33 |
as_light()
from bootwrap import Table
table = Table(
["Column 1", "Column 2", "Column 3"],
[
["Value 11", "Value 12", "Value 13"],
["Value 21", "Value 22", "Value 23"],
["Value 31", "Value 32", "Value 33"],
]
)
table.head.as_light()
table
Column 1 | Column 2 | Column 3 |
---|---|---|
Value 11 | Value 12 | Value 13 |
Value 21 | Value 22 | Value 23 |
Value 31 | Value 32 | Value 33 |
Table.Body(body)
transform(index, entity, fn)
Name | Type | Description |
---|---|---|
index |
int
|
The column index to which transformation is applied; |
entity |
Entity
|
The entity to which transformation is applied; |
fn |
func
|
The function to use for transformation. |
from bootwrap import Table, TableEntity, Text
table = Table(
["Column 1", "Column 2", "Column 3"],
[
["val1", "int", "this is a description for val1;"],
["val2", "str", "this is a description for val2;"],
["val3", "bool", "this is a description for val3;"],
]
)
table.body.transform(
0,
TableEntity.CELL,
lambda v: "font-weight-bold" if v.startswith("val") else ""
)
table.body.transform(
0,
TableEntity.ROW,
lambda v: "bg-warning" if v == "val2" else ""
)
table.body.transform(
1,
TableEntity.VALUE,
lambda v: f"{v}
"
)
table
Column 1 | Column 2 | Column 3 |
---|---|---|
val1 |
int
|
this is a description for val1; |
val2 |
str
|
this is a description for val2; |
val3 |
bool
|
this is a description for val3; |
Text(content)
Name | Type | Description |
---|---|---|
content |
str
|
The textual content. |
from bootwrap import Text, Panel
txt = Text("Text")
txt_outline = Text("Text with border").as_outline()
txt_primary = Text("Text of primary color").as_primary()
txt_primary_outline = Text("Text of primary color with border").as_primary().as_outline()
Panel(
txt,
txt_outline,
txt_primary,
txt_primary_outline
).vertical()
as_code(language='python')
Name | Type | Description |
---|---|---|
language |
str
|
The language to highlight, currently supported: "python", "json", "yaml", "bash" |
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Panel, Text
Panel(
Text('print("language python")').as_code("python"),
Text('{"language": "json"}').as_code("json"),
Text("language: yaml").as_code("yaml"),
Text("~$ ls language/bash").as_code("bash")
).vertical()
print("language python")
{"language": "json"}
language: yaml
~$ ls language/bash
as_heading(level)
Name | Type | Description |
---|---|---|
level |
int
|
The heading level; |
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Panel, Text
Panel(
Text("Header text 1").as_heading(1),
Text("Header text 2").as_heading(2),
Text("Header text 3").as_heading(3),
Text("Header text 4").as_heading(4),
Text("Header text 5").as_heading(5),
Text("Header text 6").as_heading(6)
)
as_muted()
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Text
Text("Muted text").as_muted()
as_paragraph()
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Panel, Text
Panel(
Text("Paragraph 1").as_paragraph(),
Text("Paragraph 2").as_paragraph(),
Text("Paragraph 3").as_paragraph()
)
Paragraph 1
Paragraph 2
Paragraph 3
as_small()
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Text, Panel
txt_small = Text("Small text").as_small()
txt_small_outline = Text("Small text with border").as_small().as_outline()
txt_small_primary = Text("Small text of primary color").as_small().as_primary()
txt_small_primary_outline = Text("Small text of primary color with border").as_small().as_primary().as_outline()
Panel(
txt_small,
txt_small_outline,
txt_small_primary,
txt_small_primary_outline
).vertical()
as_strong()
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Text, Panel
txt_strong = Text("Strong text").as_strong()
txt_strong_outline = Text("Strong text with border").as_strong().as_outline()
txt_strong_primary = Text("Strong text of primary color").as_strong().as_primary()
txt_strong_primary_outline = Text("Strong text of primary color with border").as_strong().as_primary().as_outline()
Panel(
txt_strong,
txt_strong_outline,
txt_strong_primary,
txt_strong_primary_outline
).vertical()
Toast(title=None, description=None, marker=None, figure=None, hide_delay=None)
Name | Type | Description |
---|---|---|
title |
str|WebComponent
|
The item title. |
description |
str|WebComponent
|
The item description. |
marker |
str|WebComponent
|
The item marker. |
figure |
str|WebComponent
|
The item figure. |
from bootwrap import Panel, Toast, Button, Icon, Text, Javascript
tst_example = Toast(
title="Bootwrap",
description="Hello, world! This is a toast message.",
marker="11 mins ago",
figure=Icon("fa-solid fa-info"),
)
btn_show_toast = Button("Show toast")
action = Javascript(
script='''
$("#btn_show_toast").on("click",function(){
$("#tst_example").toast("show");
});
''',
submap={
"tst_example": tst_example,
"btn_show_toast": btn_show_toast,
}
)
Panel(
tst_example,
btn_show_toast,
action
)
Make
Toast
with and without title
.
from bootwrap import Panel, Toast, Button, Icon, Text, Javascript
tst_with_title = Toast(
title="Bootwrap",
description="Hello, world! This is a toast message.",
marker="11 mins ago",
figure=Icon("fa-solid fa-info"),
)
tst_without_title = Toast(
description="Hello, world! This is a toast message.",
)
btn_show_toast_with_title = Button("Show toast with title")
btn_show_toast_without_title = Button("Show toast without title")
action = Javascript(
script='''
$("#btn_show_toast_with_title").on("click",function(){
$("#tst_with_title").toast("show");
});
$("#btn_show_toast_without_title").on("click",function(){
$("#tst_without_title").toast("show");
});
''',
submap={
"tst_with_title": tst_with_title,
"tst_without_title": tst_without_title,
"btn_show_toast_with_title": btn_show_toast_with_title,
"btn_show_toast_without_title": btn_show_toast_without_title,
}
)
Panel(
tst_with_title,
tst_without_title,
btn_show_toast_with_title,
btn_show_toast_without_title,
action
)
Change
Toast
appearance using the one of the following functions
as_primary()
,
as_secondary()
,
as_success()
,
as_warning()
,
as_danger()
,
as_info()
,
as_light()
, and
as_dark()
.
from bootwrap import Panel, Toast, Button, Icon, Text, Javascript
tst_with_title = Toast(
title="Bootwrap",
description="Hello, world! This is a toast message.",
marker="11 mins ago",
figure=Icon("fa-solid fa-info"),
).as_primary()
tst_without_title = Toast(
description="Hello, world! This is a toast message.",
).as_primary()
btn_show_toast_with_title = Button("Show toast with title").as_primary()
btn_show_toast_without_title = Button("Show toast without title").as_primary()
action = Javascript(
script='''
$("#btn_show_toast_with_title").on("click",function(){
$("#tst_with_title").toast("show");
});
$("#btn_show_toast_without_title").on("click",function(){
$("#tst_without_title").toast("show");
});
''',
submap={
"tst_with_title": tst_with_title,
"tst_without_title": tst_without_title,
"btn_show_toast_with_title": btn_show_toast_with_title,
"btn_show_toast_without_title": btn_show_toast_without_title,
}
)
Panel(
tst_with_title,
tst_without_title,
btn_show_toast_with_title,
btn_show_toast_without_title,
action
)
Make
Toast
without filling with surrounded by color border using the following function
as_outline()
.
from bootwrap import Panel, Toast, Button, Icon, Text, Javascript
tst_with_title = Toast(
title="Bootwrap",
description="Hello, world! This is a toast message.",
marker="11 mins ago",
figure=Icon("fa-solid fa-info"),
).as_success().as_outline()
tst_without_title = Toast(
description="Hello, world! This is a toast message.",
).as_success().as_outline()
btn_show_toast_with_title = Button("Show toast with title").as_success().as_outline()
btn_show_toast_without_title = Button("Show toast without title").as_success().as_outline()
action = Javascript(
script='''
$("#btn_show_toast_with_title").on("click",function(){
$("#tst_with_title").toast("show");
});
$("#btn_show_toast_without_title").on("click",function(){
$("#tst_without_title").toast("show");
});
''',
submap={
"tst_with_title": tst_with_title,
"tst_without_title": tst_without_title,
"btn_show_toast_with_title": btn_show_toast_with_title,
"btn_show_toast_without_title": btn_show_toast_without_title,
}
)
Panel(
tst_with_title,
tst_without_title,
btn_show_toast_with_title,
btn_show_toast_without_title,
action
)
Make
Toast
with custom delay.
from bootwrap import Panel, Toast, Button, Icon, Text, Javascript
tst_example = Toast(
title="Bootwrap",
description="Hello, world! This is a toast message will hide in 5 sec.",
marker="11 mins ago",
figure=Icon("fa-solid fa-info"),
hide_delay=5000
)
btn_show_toast = Button("Show toast")
action = Javascript(
script='''
$("#btn_show_toast").on("click",function(){
$("#tst_example").toast("show");
});
''',
submap={
"tst_example": tst_example,
"btn_show_toast": btn_show_toast,
}
)
Panel(
tst_example,
btn_show_toast,
action
)