Document Padding/Color classes and methods
Signed-off-by: Adam Stokes <adam.stokes@ubuntu.com>
This commit is contained in:
parent
ffc4453474
commit
a80d6b16d0
|
@ -31,8 +31,8 @@ class Header(WidgetWrap):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
border = Color.frame_header(Text(" "))
|
border = Color.frame_header(Text(" "))
|
||||||
title_widget = Padding.left_10(Color.body(Text(self.title)))
|
title_widget = Padding.push_10(Color.body(Text(self.title)))
|
||||||
excerpt_widget = Padding.left_10(Color.body(Text(self.excerpt)))
|
excerpt_widget = Padding.push_10(Color.body(Text(self.excerpt)))
|
||||||
pile = Pile([border,
|
pile = Pile([border,
|
||||||
title_widget,
|
title_widget,
|
||||||
Text(""),
|
Text(""),
|
||||||
|
@ -52,7 +52,7 @@ class Footer(WidgetWrap):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
border = Color.frame_footer(Text(""))
|
border = Color.frame_footer(Text(""))
|
||||||
message_widget = Padding.left_10(Color.body(Text(self.message)))
|
message_widget = Padding.push_10(Color.body(Text(self.message)))
|
||||||
status = Pile([border, message_widget])
|
status = Pile([border, message_widget])
|
||||||
super().__init__(status)
|
super().__init__(status)
|
||||||
|
|
||||||
|
|
|
@ -47,15 +47,67 @@ def apply_padders(cls):
|
||||||
partialmethod(_Padding, align='center',
|
partialmethod(_Padding, align='center',
|
||||||
width=('relative', i)))
|
width=('relative', i)))
|
||||||
setattr(cls, 'left_{}'.format(i),
|
setattr(cls, 'left_{}'.format(i),
|
||||||
partialmethod(_Padding, left=i))
|
partialmethod(_Padding, align='left',
|
||||||
|
width=('relative', i)))
|
||||||
setattr(cls, 'right_{}'.format(i),
|
setattr(cls, 'right_{}'.format(i),
|
||||||
partialmethod(_Padding, right=i))
|
partialmethod(_Padding, align='right',
|
||||||
|
width=('relative', i)))
|
||||||
return cls
|
return cls
|
||||||
|
|
||||||
|
|
||||||
@apply_padders
|
@apply_padders
|
||||||
class Padding:
|
class Padding:
|
||||||
""" Partial methods for :class:`urwid.Padding` """
|
""" Padding methods
|
||||||
|
|
||||||
|
.. py:meth:: push_X(:class:`urwid.Widget`)
|
||||||
|
|
||||||
|
This method supports padding the left side of the widget
|
||||||
|
from 1-99, for example:
|
||||||
|
|
||||||
|
.. code::
|
||||||
|
|
||||||
|
Padding.push_20(Text("This will be indented 20 columns")
|
||||||
|
|
||||||
|
.. py:meth:: pull_X(:class:`urwid.Widget`)
|
||||||
|
|
||||||
|
This method supports padding the right side of the widget
|
||||||
|
from 1-99, for example:
|
||||||
|
|
||||||
|
.. code::
|
||||||
|
|
||||||
|
Padding.pull_20(Text("This will be right indented 20 columns")
|
||||||
|
|
||||||
|
.. py:meth:: center_X(:class:`urwid.Widget`)
|
||||||
|
|
||||||
|
This method centers a widget with X being the relative width of
|
||||||
|
the widget.
|
||||||
|
|
||||||
|
.. code::
|
||||||
|
|
||||||
|
Padding.center_10(Text("This will be centered with a "
|
||||||
|
"width of 10 columns"))
|
||||||
|
|
||||||
|
.. py:meth:: left_X(:class:`urwid.Widget`)
|
||||||
|
|
||||||
|
This method aligns a widget left with X being the relative width of
|
||||||
|
the widget.
|
||||||
|
|
||||||
|
.. code::
|
||||||
|
|
||||||
|
Padding.left_10(Text("This will be left aligned with a "
|
||||||
|
"width of 10 columns"))
|
||||||
|
|
||||||
|
.. py:meth:: right_X(:class:`urwid.Widget`)
|
||||||
|
|
||||||
|
This method right aligns a widget with X being the relative width of
|
||||||
|
the widget.
|
||||||
|
|
||||||
|
.. code::
|
||||||
|
|
||||||
|
Padding.right_10(Text("This will be right aligned with a "
|
||||||
|
"width of 10 columns"))
|
||||||
|
|
||||||
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@ -74,5 +126,16 @@ def apply_style_map(cls):
|
||||||
|
|
||||||
@apply_style_map
|
@apply_style_map
|
||||||
class Color:
|
class Color:
|
||||||
""" Partial methods for :class:`urwid.AttrMap` """
|
""" Partial methods for :class:`subiquity.palette.STYLES`
|
||||||
|
|
||||||
|
.. py:meth:: frame_header(:class:`urwid.Widget`)
|
||||||
|
|
||||||
|
This method colors widget based on the style map used.
|
||||||
|
|
||||||
|
.. code::
|
||||||
|
|
||||||
|
Color.frame_header(Text("This will use foreground and background "
|
||||||
|
"defined from the STYLES attribute"))
|
||||||
|
|
||||||
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
Loading…
Reference in New Issue