Package ocempgui :: Package widgets :: Module Label :: Class Label
[show private | hide private]
[frames | no frames]

Type Label

 object --+            
          |            
INotifyable --+        
              |        
     BaseObject --+    
                  |    
     object --+   |    
              |   |    
         Sprite --+    
                  |    
         BaseWidget --+
                      |
                     Label


Label (text) -> Label

A simple widget class, which can display text.

The Label widget is able to display a short amount of text. It
supports a mnemonic keybinding to activate other widgets.

The text to display on the Label can be set through the 'text'
attribute or set_text() method. To create a mnemonic within the
text, a hash ('#') has to precede the the wanted character. A normal
hash character can be created using two hashes ('##'). If more than
one mnemonic identifier are placed in the text (like in '#Two
#mnemonics', only the first one will be used, while all others will
be ignored.

label.text = '#Mnemonics' # Use the M character as mnemonic.
label.text = 'Use ##1'    # Creates the text 'Use #1'.
label.set_text ('No mnemonic here')
label.set_text ('#Two #mnemonics') # Only the first '#' will be used.

A widget can be bound to the mnemonic with the 'widget' attribute or
set_widget() method. Whenever the mnemonic is activated, the
connected widget will receive the focus.

label.widget = widget
label.set_widget (widget)

The 'padding' attribute and set_padding() method are used to place a
certain amount of pixels between the text and the outer edges of the
Label.

label.padding = 10
label.set_padding (10)

The Label supports the display of multiple text lines via the
'multiline' attribute and set_multiline() method. If it is set to
True, the text to display will be splitted into several lines using
the newline character '\n' and each line will be displayed beneath
the previous one.

label.multiline = True
label.set_multiline (True)

The layout for the text within the Label can be set individually
using the set_align() method and 'align' attribute. Alignments can be
combined, which means, that a ALIGN_TOP | ALIGN_LEFT would align the
text at the topleft corner of the Label.

However, not every alignment make sense, so a ALIGN_TOP | ALIGN_BOTTOM
would cause the widget to be placed at the top. The priority
order for the alignment follows. The lower the value, the higher the
priority.

Alignment      Priority
-----------------------
ALIGN_TOP         0
ALIGN_BOTTOM      1
ALIGN_LEFT        0
ALIGN_RIGHT       1
ALIGN_NONE        2

Default action (invoked by activate()):
None

Mnemonic action (invoked by activate_mnemonic()):
The activate() method of the connected widget will be invoked.

Attributes:
text      - The text to display on the Label.
widget    - The widget to focus, if the mnemonic is activated.
padding   - Additional padding between text and borders. Default is 2.
mnemonic  - A tuple with index location character of the mnemonic.
multiline - Indicates, whether the text spans over multiple lines.
            Default is False.
linespace - The line space in multiline mode.
align     - The alignment of the text on the Label.
lines     - A list containing the single text lines.

Method Summary
  __init__(self, text)
  activate(self)
L.activate () -> None
  activate_mnemonic(self, mnemonic)
L.activate_mnemonic (...) -> bool
  draw_bg(self)
L.draw_bg () -> Surface
  get_lines(self)
L.get_lines () -> list
  set_align(self, align)
L.set_align (...) -> None
  set_focus(self, focus)
L.set_focus (...) -> bool
  set_linespace(self, linespace)
L.set_linespace (...) -> None
  set_multiline(self, multiline)
L.set_multiline (...) -> None
  set_padding(self, padding)
L.set_padding (...) -> None
  set_text(self, text)
L.set_text (...) -> None
  set_widget(self, widget)
L.set_widget (...) -> None
  _get_mnemonic(self, text)
L._get_mnemonic (...) -> str
    Inherited from BaseWidget
  check_sizes(self, width, height)
W.check_sizes (...) -> int, int
  create_style(self)
W.create_style () -> WidgetStyle
  debug_update(self)
For debugging usage only
  destroy(self)
W.destroy () -> None
  draw(self)
W.draw () -> None
  get_style(self)
W.get_style () -> WidgetStyle
  initclass(cls)
B.initclass () -> None (Class method)
  lock(self)
W.lock () -> None
  notify(self, event)
W.notify (...) -> None
  rect_to_client(self, rect)
W.rect_to_client (...) -> pygame.Rect
  set_depth(self, depth)
W.set_depth (...) -> None
  set_dirty(self, dirty, update)
W.set_dirty (...) -> None
  set_entered(self, entered)
W.set_entered (...) -> None
  set_event_area(self, area)
W.set_event_area (...) -> None
  set_event_manager(self, manager)
W.set_event_manager (...) -> None
  set_index(self, index)
W.set_index (...) -> None
  set_indexable(self, indexable)
W.set_indexable (...) -> None
  set_maximum_size(self, width, height)
W.set_maximum_size (...) -> None
  set_minimum_size(self, width, height)
W.set_minimum_size (...) -> None
  set_opacity(self, opacity)
W.set_opacity (...) -> None
  set_position(self, x, y)
W.set_position (...) -> None
  set_sensitive(self, sensitive)
W.set_sensitive (...) -> None
  set_size(self, width, height)
W.set_size (...) -> None
  set_state(self, state)
W.set_state (...) -> None
  set_style(self, style)
W.set_style (...) -> None
  set_tooltip(self, tooltip)
W.set_tooltip (...) -> None
  unlock(self)
W.unlock () -> None
  update(self, **kwargs)
W.update (...) -> None
  _get_rect(self)
W._get_rect () -> pygame.Rect
  _get_rect_attr(self, attr)
W._get_rect_attr (...) -> var
  _set_rect_attr(self, attr, value)
W._set_rect_attr (...) -> None
    Inherited from BaseObject
  connect_signal(self, signal, callback, *data)
B.connect_signal (...) -> EventCallback
  disconnect_signal(self, event)
B.disconnect_signal (...) -> None
  emit(self, signal, data)
B.emit (...) -> bool
  run_signal_handlers(self, signal, *data)
B.run_signal_handlers (...) -> None
    Inherited from Sprite
  __repr__(self)
  add(self, *groups)
add(group or list of of groups, ...) add a sprite to container
  add_internal(self, group)
  alive(self)
alive() -> bool check to see if the sprite is in any groups
  groups(self)
groups() -> list of groups list used sprite containers
  kill(self)
kill() remove this sprite from all groups
  remove(self, *groups)
remove(group or list of groups, ...) remove a sprite from container
  remove_internal(self, group)
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
x.__hash__() <==> hash(x)
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
  __str__(x)
x.__str__() <==> str(x)

Property Summary
  align: The alignment to use for the text.
  lines: A list containing the single text lines.
  linespace: The line space in multiline mode.
  mnemonic: The index and character of the mnemonic.
  multiline: Indicates, whether the text spans over multiple lines.
  padding: Additional padding between text and borders.
  text: The text to display on the Label.
  widget: The connected widget for the mnemonic key.
    Inherited from BaseWidget
  bottom
  bottomleft
  bottomright
  center
  centerx
  centery
  controls: Widgets associated with the widget.
  depth: The z-axis layer depth of the widget.
  dirty: Indicates, whether the widget need to be redrawn.
  entered: Indicates, whether the widget is entered.
  eventarea: The area, which gets the events.
  focus: The focus of the widget.
  h
  height
  image: The visible surface of the widget.
  index: The tab index position of the widget.
  indexable: The IIndexable, the widget is attached to.
  left
  locked: Indicates, whether the widget is locked.
  maxsize: The maximum size to occupy by the widget.
  midbottom
  midleft
  midright
  midtop
  minsize: The guaranteed size of the widget.
  opacity: The opacity of the widget.
  position: The position of the topleft corner.
  rect: The area occupied by the widget.
  right
  sensitive: The sensitivity of the widget.
  size
  state: The current state of the widget.
  style: The style of the widget.
  tooltip: The tool tip text to display for the widget.
  top
  topleft
  topright
  w
  width
  x
  y
    Inherited from BaseObject
  manager: The event manager to use by the object.

Instance Method Details

activate(self)

L.activate () -> None

Activates the Label.

Note: Labels can not be activated by default, thus this method does not do anything.
Overrides:
ocempgui.widgets.BaseWidget.BaseWidget.activate

activate_mnemonic(self, mnemonic)

L.activate_mnemonic (...) -> bool

Activates the mnemonic widget of the Label.

Checks, if the Label uses the passed mnemonic, invokes the activate() method of its mnemonic widget on a successful check and returns True, otherwise False.
Overrides:
ocempgui.widgets.BaseWidget.BaseWidget.activate_mnemonic

draw_bg(self)

L.draw_bg () -> Surface

Draws the Label background surface and returns it.

Creates the visible background surface of the Label and returns it to the caller.
Overrides:
ocempgui.widgets.BaseWidget.BaseWidget.draw_bg

get_lines(self)

L.get_lines () -> list

Gets a list with the text lines.

Gets a list of lines from the set text. The text will be splitted using the newline character '\n' and returned as a list.

If the 'multiline' attribute is set to false, a single text line is returned.

set_align(self, align)

L.set_align (...) -> None

Sets the alignment for the text on the Label.

Raises a TypeError, if the passed argument is not a value from ALIGN_TYPES.

set_focus(self, focus=True)

L.set_focus (...) -> bool

Overrides the default widget input focus.

Labels cannot be focused by default, thus this method always returns False and does not do anything.
Overrides:
ocempgui.widgets.BaseWidget.BaseWidget.set_focus

set_linespace(self, linespace)

L.set_linespace (...) -> None

Sets the line space between each line in multiline mode.

The line space is defined in pixels.

Raises a TypeError, if the passed argument is not a positive integer.

set_multiline(self, multiline)

L.set_multiline (...) -> None

Sets the multiline support of the Label.

The multiline support indicates, that the text to display on the label can span over several lines. The text usually will be splitted using the newline character '\n'.

set_padding(self, padding)

L.set_padding (...) -> None

Sets the padding between the edges and text of the Label.

The padding value is the amount of pixels to place between the edges of the Label and the displayed text.

Raises a TypeError, if the passed argument is not a positive integer.

Note: If the 'size' attribute is set, it can influence the visible space between the text and the edges. That does not mean, that any padding is set.

set_text(self, text)

L.set_text (...) -> None

Sets the text of the Label to the passed argument.

Sets the text of the Label to the passed argument. If the text contains a hash ('#') character, then the character, the hash precedes, will be used as a mnemonic (see also set_widget()). Any other single hash character will be dropped and ignored.

To create a normal hash character to display, use two '##'.

Raises a TypeError, if the passed argument is not a string or unicode.

set_widget(self, widget)

L.set_widget (...) -> None

Sets the widget to activate, if the mnemonic key gets pressed.

Note: This method only works as supposed using a render loop, which supports the Renderer class specification.

Raises a TypeError, if the passed argument does not inherit from the BaseWidget class.

_get_mnemonic(self, text)

L._get_mnemonic (...) -> str

Sets the mnemonic position (if any).

Sets the internal mnemonic position to first position with a single '#'.

Property Details

align

The alignment to use for the text.
Get Method:
unknown-696314148(...)
Set Method:
unknown-696314204(...)

lines

A list containing the single text lines.
Get Method:
unknown-696314092(...)

linespace

The line space in multiline mode.
Get Method:
unknown-696313980(...)
Set Method:
unknown-696314036(...)

mnemonic

The index and character of the mnemonic.
Get Method:
unknown-696313812(...)

multiline

Indicates, whether the text spans over multiple lines.
Get Method:
unknown-696313868(...)
Set Method:
unknown-696313924(...)

padding

Additional padding between text and borders.
Get Method:
unknown-696313700(...)
Set Method:
unknown-696313756(...)

text

The text to display on the Label.
Get Method:
unknown-696313476(...)
Set Method:
unknown-696313532(...)

widget

The connected widget for the mnemonic key.
Get Method:
unknown-696313588(...)
Set Method:
unknown-696313644(...)

Generated by Epydoc 2.1 on Thu Jan 10 10:18:43 2008 http://epydoc.sf.net