Module albow.widgets.ValueDisplay
Source code
from pygame import Surface
from albow.core.ui.Widget import Widget
from albow.widgets.Control import Control
from albow.utils import blit_in_rect
class ValueDisplay(Control, Widget):
    """
    A ValueDisplay is a Control that provides a read-only textual display of a value.
    """
    format = "%s"
    """
    Format string to be used when displaying the value. Also see the format_value() method below.
    """
    align  = 'l'
    """
        How to align the value.  Default is 'l'
    """
    def __init__(self, width=100, **kwds):
        Widget.__init__(self, **kwds)
        self.set_size_for_text(width)
    def draw(self, surface: Surface):
        value = self.value
        text  = self.format_value(value)
        buf   = self.font.render(text, True, self.fg_color)
        frame = surface.get_rect()
        blit_in_rect(surface, buf, frame, self.align, self.margin)
    def format_value(self, value):
        if value is not None:
            return self.format % value
        else:
            return ""Classes
- class ValueDisplay (width=100, **kwds)
- 
A ValueDisplay is a Control that provides a read-only textual display of a value. Source codeclass ValueDisplay(Control, Widget): """ A ValueDisplay is a Control that provides a read-only textual display of a value. """ format = "%s" """ Format string to be used when displaying the value. Also see the format_value() method below. """ align = 'l' """ How to align the value. Default is 'l' """ def __init__(self, width=100, **kwds): Widget.__init__(self, **kwds) self.set_size_for_text(width) def draw(self, surface: Surface): value = self.value text = self.format_value(value) buf = self.font.render(text, True, self.fg_color) frame = surface.get_rect() blit_in_rect(surface, buf, frame, self.align, self.margin) def format_value(self, value): if value is not None: return self.format % value else: return ""AncestorsClass variables- var align
- 
How to align the value. Default is 'l' 
- var format
- 
Format string to be used when displaying the value. Also see the format_value() method below. 
 Methods- def format_value(self, value)
- 
Source codedef format_value(self, value): if value is not None: return self.format % value else: return ""
 Inherited members- Control:
- Widget:
- Widget:- add
- add_anchor
- add_centered
- anchor
- attention_lost
- augment_mouse_event
- bg_color
- bg_image
- border_color
- border_width
- call_handler
- call_parent_handler
- defer_drawing
- dismiss
- draw_over
- fg_color
- focus
- focus_switch
- font
- get_cursor
- get_focus
- get_margin_rect
- get_root
- get_top_widget
- get_visible
- global_to_local
- has_focus
- inherited
- invalidate
- is_gl_container
- key_down
- key_up
- local_to_global
- margin
- menu_bar
- parent
- parent_resized
- present
- rect
- relative_mode
- remove
- remove_anchor
- resized
- scale_bg
- sel_color
- set_parent
- set_size_for_text
- tab_stop
- visible