Messages

Messages are the objects you use to send instructions to the manager, and they are the objects the manager uses to send data back to you.

Command Messages

These messages should be used by your application to control the manager running the terminal display. They should never be sent by the manager to the application.

class thurible.messages.Alert(name: str = 'alert', title: str = '', text: str = 'Error.', options: Sequence[Option] = (Option(name='Continue', hotkey=''),))[source]

Create a new thurible.messages.Alert object. This object is a command message used to instruct a manager to show an alert message to the user.

Parameters:
  • name – (Optional.) The name the manager will use to store the thurible.Dialog object created in response to this message. The default name is “alert”.

  • title – (Optional.) The title of the alert.

  • text – (Optional.) The text of the alert. The default value is “Error.”

  • options – (Optional.) The options given to the user for responding to the alert. The default is “Continue”.

Returns:

An thurible.messages.Alert object.

Return type:

thurible.messages.Alert

Usage:

To create a thurible.messages.Alert object:

import thurible.messages as msgs
from thurible.menu import Option

name = 'alert1'
title = 'Warning'
text = 'Something broke.'
option_1 = Option('Panic', 'p')
option_2 = Option('Flee', 'f')
options = [option_1, option_2]
msg = msgs.Alert(name, title, text, options)
class thurible.messages.Delete(name: str)[source]

Create a new thurible.messages.Delete object. This object is a command message used to instruct a manager to delete a stored panel.

Parameters:

name – The name of the panel to delete.

Returns:

An thurible.messages.Delete object.

Return type:

thurible.messages.Delete

Usage:

To create a thurible.messages.Delete object:

import thurible.messages as msgs

name = 'alert1'
msg = msgs.Delete(name)
class thurible.messages.Dismiss(name: str = 'alert')[source]

Create a new thurible.messages.Dismiss object. This object is a command message used to stop displaying an alert.

Parameters:

name – (Optional.) The name of the panel to dismiss.

Returns:

An thurible.messages.Dismiss object.

Return type:

thurible.messages.Dismiss

Usage:

To create a thurible.messages.Dismiss object:

import thurible.messages as msgs

name = 'alert1'
msg = msgs.Dismiss(name)
class thurible.messages.End(text: str = '')[source]

Create a new thurible.messages.End object. This object is a command message used to instruct a manager to end the manager loop and quit.

Parameters:

text – (Optional.) A message to print for the user after the manager loop ends.

Returns:

An thurible.messages.End object.

Return type:

thurible.messages.End

Usage:

To create a thurible.messages.End object:

import thurible.messages as msgs

name = 'Goodbye!'
msg = msgs.End(name)
class thurible.messages.Ping(name: str)[source]

Create a new thurible.messages.Ping object. This object is a command message used to instruct a manager to reply with a thurible.message.Pong message, proving the manager is still listening for and responding to messages.

Parameters:

name – A unique name used to identify the resulting thurible.message.Pong message as being caused by this message.

Returns:

An thurible.messages.Ping object.

Return type:

thurible.messages.Ping

Usage:

To create a thurible.messages.Ping object:

import thurible.messages as msgs

name = 'ping1'
msg = msgs.Ping(name)
class thurible.messages.Show(name: str)[source]

Create a new thurible.messages.Show object. This object is a command message used to instruct a manager to display a stored panel.

Parameters:

name – The name of the panel to display.

Returns:

An thurible.messages.Show object.

Return type:

thurible.messages.Show

Usage:

To create a thurible.messages.Show object:

import thurible.messages as msgs

name = 'alert1'
msg = msgs.Show(name)
class thurible.messages.Showing(name: str = '')[source]

Create a new thurible.messages.Showing object. This object is a command message used to instruct a manager to respond with a thurible.messages.Shown message with the name of the currently displayed panel.

Parameters:

name – (Optional.) A unique name used to identify the resulting thurible.message.Shown message as being caused by this message.

Returns:

An thurible.messages.Showing object.

Return type:

thurible.messages.Showing

Usage:

To create a thurible.messages.Showing object:

import thurible.messages as msgs

name = 'alert1'
msg = msgs.Showing(name)
class thurible.messages.Store(name: str, display: Panel)[source]

Create a new thurible.messages.Store object. This object is a command message used to instruct a manager to store a panel for later display.

Parameters:
  • name – The name of the panel to store.

  • display – The panel to store.

Returns:

An thurible.messages.Store object.

Return type:

thurible.messages.Store

Usage:

To create a thurible.messages.Store object:

import thurible.messages as msgs
from thurible import Dialog

name = 'alert1'
dialog = Dialog('Be alerted!')
msg = msgs.Store(name, dialog)
class thurible.messages.Storing(name: str = '')[source]

Create a new thurible.messages.Storing object. This object is a command message used to instruct a manager to respond with a thurible.message.Stored object containing the names of the currently stored panels.

Parameters:

name – (Optional.) A unique name used to identify the resulting thurible.message.Stored message as being caused by this message.

Returns:

An thurible.messages.Storing object.

Return type:

thurible.messages.Storing

Usage:

To create a thurible.messages.Storing object:

import thurible.messages as msgs

name = 'check_stored_displays'
msg = msgs.Storing(name)
class thurible.Update(text: str)[source]

Create a new thurible.log.Update object. This object is a command message used to instruct the currently displayed thurible.Log to add the text given in the message.

Parameters:

text – The message to add to the panel.

Returns:

An thurible.Update object.

Return type:

thurible.Update

Usage:

To create a new thurible.Update object:

import thurible

update = thurible.Update('spam')
class thurible.Tick(message: str = '')[source]

Create a new thurible.progress.Tick object. When sent to thurible.Progress.update(), this will cause the progress bar to advance.

Parameters:

message – A message to display.

Returns:

A thurible.Tick object.

Return type:

thurible.Tick

Usage:

To create a message to advance a thurible.Progress object with the text “another step completed”:

import thurible

tick = thurible.Tick('another step completed')
class thurible.NoTick(message: str = '')[source]

Create a new thurible.progress.NoTick object. When sent to thurible.Progress.update(), this will not cause the progress bar to advance.

Parameters:

message – A message to display.

Returns:

A thurible.NoTick object.

Return type:

thurible.NoTick

Usage:

To create a message to advance a thurible.Progress object with the text “still working…”:

import thurible

notick = thurible.NoTick('still working...')

Response Messages

These messages are used by managers to respond to or alert your application. They should never be sent by the application to the manager.

class thurible.messages.Data(value: str)[source]

Create a new thurible.messages.Data object. This object is a response message used to send data back to the application.

Parameters:

value – The data being sent to the application.

Returns:

An thurible.messages.Data object.

Return type:

thurible.messages.Data

Usage:

To create a thurible.messages.Data object:

import thurible.messages as msgs

name = 'datum'
msg = msgs.Data(name)
class thurible.messages.Ending(reason: str = '', ex: Exception | None = None)[source]

Create a new thurible.messages.Ending object. This object is a response message used to inform the application that the manager is ending.

Parameters:
  • reason – (Optional.) The reason the manager loop is ending.

  • ex – (Optional.) The exception causing the manager loop to end.

Returns:

An thurible.messages.Ending object.

Return type:

thurible.messages.Ending

Usage:

To create a thurible.messages.Ending object:

import thurible.messages as msgs

name = 'keyboard interrupt'
ex = KeyboardInterrupt
msg = msgs.Ending(name, ex)
class thurible.messages.Pong(name: str)[source]

Create a new thurible.messages.Pong object. This object is a response message used to respond to a thurible.messages.Ping message.

Parameters:

name – The name of the thurible.messages.Ping message that caused this response.

Returns:

An thurible.messages.Pong object.

Return type:

thurible.messages.Pong

Usage:

To create a thurible.messages.Pong object:

import thurible.messages as msgs

name = 'pong1'
msg = msgs.Pong(name)
class thurible.messages.Shown(name: str, display: str)[source]

Create a new thurible.messages.Shown object. This object is a response message used to respond to a thurible.messages.Showing message.

Parameters:
Returns:

An thurible.messages.Shown object.

Return type:

thurible.messages.Shown

Usage:

To create a thurible.messages.Shown object:

import thurible.messages as msgs

name = 'check_display'
display = 'alert1'
msg = msgs.Shown(name, display)
class thurible.messages.Stored(name: str, stored: tuple[str, ...])[source]

Create a new thurible.messages.Stored object. This object is a response message used to respond to a thurible.messages.Storing message.

Parameters:
Returns:

An thurible.messages.Stored object.

Return type:

thurible.messages.Stored

Usage:

To create a thurible.messages.Stored object:

import thurible.messages as msgs

name = 'check_stored_displays'
stored = ['alert1', 'text1', 'doc_menu', 'text2',]
msg = msgs.Stored(name, stored)