August'24: Kamaelia is in maintenance mode and will recieve periodic updates, about twice a year, primarily targeted around Python 3 and ecosystem compatibility. PRs are always welcome. Latest Release: 1.14.32 (2024/3/24)

Kamaelia.UI.Pygame.Ticker

Pygame text 'Ticker'

Displays text in pygame a word at a time as a 'ticker'.

NOTE: This component is very much a work in progress. Its capabilities and API is likely to change substantially in the near future.

Example Usage

Ticker displaying text from a file:

Pipeline( RateControlledFileReader("textfile","lines",rate=1000),
          Ticker(position=(100,100))
        ).run()

How does it work?

The component requests a display surface from the Pygame Display service component. This is used as the ticker.

Send strings containing lines of text to the Ticker component. Do not send strings with words split between one string and the next. It displays the words as a 'ticker' one word at a time. Text is automatically wrapped from one line to the next. Once the bottom of the ticker is reached, the text automatically jump-scrolls up a line to make more room.

The text is normalised by the ticker. Multiple spaces between words are collapsed to a single space. Linefeeds are ignored.

NOTE: 2 consecutive linefeeds currently results in a special message being sent out of the "_displaysignal" outbox. This is work-in-progress aimed at new features. It is only documented here for completeness and should not be relied upon.

You can set the text size, colour and line spacing. You can also set the background colour, outline (border) colour and width. You can also specify the size and position of the ticker

NOTE: Specifying the outline width currently does not work for any value other than 1.

NOTE: Specify the size of the ticker with the render_right and render_bottom arguments. Specifying render_left and render_top arguments with values other than 1 results in parts of the ticker being obscured.

The ticker displays words at a constant rate - it self regulates its display speed.

Whilst it is running, sending any message to the "pausebox" inbox will pause the Ticker. It will continue to buffer incoming text. Any message sent to the "unpausebox" inbox will cause the Ticker to resume.

Whilst running, you can change the transparency of the ticker by sending a value to the "alphacontrol" inbox between 0 (fully transparent) and 255 (fully opaque) inclusive.

If a producerFinished message is received on the "control" inbox, this component will send its own producerFinished message to the "signal" outbox and will terminate.

However, if the ticker is paused (message sent to "pausebox" inbox) then the component will ignore messages on its "control" inbox until it is unpaused by sending a message to its "unpausebox" inbox.


Kamaelia.UI.Pygame.Ticker.Ticker

class Ticker(Axon.Component.component)

Ticker(...) -> new Ticker component.

A pygame based component that displays incoming text as a ticker.

Keyword arguments (all optional):

  • text_height -- Font size in points (default=39)
  • line_spacing -- (default=text_height/7)
  • background_colour -- (r,g,b) background colour of the ticker (default=(128,48,128))
  • text_colour -- (r,g,b) colour of text (default=(232,232,48))
  • outline_colour -- (r,g,b) colour of the outline border (default=background_colour)
  • outline_width -- pixels width of the border (default=1)
  • position -- (x,y) pixels location of the top left corner
  • render_left -- pixels distance of left of text from left edge (default=1)
  • render_top -- pixels distance of top of text from top edge (default=1)
  • render_right -- pixels width of ticker (default=399)
  • render_bottom -- pixels height of ticker (default=299)

NOTE: render_left and render_top currently behave incorrectly if not set to 1

Inboxes

  • control : NOT USED (yet)
  • _displaycontrol : Shutdown messages & feedback from Pygame Display service
  • unpausebox : Any message unpauses the ticker
  • pausebox : Any message pauses the ticker
  • inbox : Specify (new) filename
  • alphacontrol : Transparency of the ticker (0=fully transparent, 255=fully opaque)

Outboxes

  • outbox : NOT USED
  • signal : NOT USED (yet)
  • _displaysignal : Shutdown signalling & sending requests to Pygame Display service

Methods defined here

Warning!

You should be using the inbox/outbox interface, not these methods (except construction). This documentation is designed as a roadmap as to their functionalilty for maintainers and new component developers.

__init__(self, **argd)

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

clearDisplay(self)

Clears the ticker of any existing text.

handleAlpha(self)

main(self)

Main loop.

renderBorder(self, display)

Draws a rectangle to form the 'border' of the ticker

requestDisplay(self, **argd)

Generator. Gets a display surface from the Pygame Display service.

Makes the request, then yields 1 until a display surface is returned.

waitBox(self, boxname)

Generator. yields 1 until data ready on the named inbox.

Feedback

Got a problem with the documentation? Something unclear that could be clearer? Want to help improve it? Constructive criticism is very welcome - especially if you can suggest a better rewording!

Please leave you feedback here in reply to the documentation thread in the Kamaelia blog.

-- Automatic documentation generator, 05 Jun 2009 at 03:01:38 UTC/GMT