GLXCurses.StatusBar module

class GLXCurses.StatusBar.StatusBar[source]

Bases: GLXCurses.Widget.Widget

A StatusBar is usually placed along the bottom of an Application. It may provide a regular commentary of the application’s status (as is usually the case in a web browser, for example), or may be used to simply output a message when the status changes, (when an upload is complete in an FTP client, for example).

Status bars in GLXCurses maintain a stack of messages. The message at the top of the each bar’s stack is the one that will currently be displayed.

Any messages added to a StatusBar’s stack must specify a context id that is used to uniquely identify the source of a message. This context id can be generated by GLXCurses.StatusBar.get_context_id(), given a message and the StatusBar that it will be added to. Note that messages are stored in a stack, and when choosing which message to display, the stack structure is adhered to, regardless of the context identifier of a message.

One could say that a StatusBar maintains one stack of messages for display purposes, but allows multiple message producers to maintain sub-stacks of the messages they produced (via context ids).

Status bars are created using GLXCurses.StatusBar.new().

Messages are added to the bar’s stack with GLXCurses.StatusBar.push().

The message at the top of the stack can be removed using GLXCurses.StatusBar.pop().

A message can be removed from anywhere in the stack if its message id was recorded at the time it was added. This is done using GLXCurses.StatusBar.remove().

new()[source]

Creates a new GLXCurses.StatusBar ready for messages.

Returns:the new StatusBar
Return type:GLXCurses.StatusBar
get_context_id(context_description='Default')[source]

Returns a new context identifier, given a description of the actual context.

Parameters:context_description (str) – textual description of what context the new message is being used in. Default if none
Returns:an context_id generate by Utils.new_id()
Return type:str
Raises:TypeError – When context_description is not a str
push(context_id, text)[source]

Push a new message onto the StatusBar’s stack.

Parameters:
  • context_id (str) – a context identifier, as returned by StatusBar.get_context_id()
  • text (str) – the message to add to the StatusBar
Returns:

a message identifier that can be used with StatusBar.remove().

Return type:

str

pop(context_id)[source]

Removes the first message in the StatusBar’s stack with the given context id.

Note that this may not change the displayed message, if the message at the top of the stack has a different context id.

Parameters:context_id (str) – a context identifier, as returned by StatusBar.get_context_id()
remove(context_id, message_id)[source]

Forces the removal of a message from a StatusBar’s stack. The exact context_id and message_id must be specified.

Parameters:
  • context_id (str) – a context identifier, as returned by StatusBar.get_context_id()
  • message_id (str) – a message identifier, as returned by StatusBar.push()
remove_all(context_id)[source]

Forces the removal of all messages from a StatusBar’s stack with the exact context_id .

Parameters:context_id (str) – a context identifier, as returned by StatusBar.get_context_id()
draw()[source]

Place the status bar from the end of the stdscr by look if it have a toolbar and a statusbar before

update_preferred_sizes()[source]