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.Alertobject. 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.Dialogobject 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.Alertobject.- Return type:
- Usage:
To create a
thurible.messages.Alertobject: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.Deleteobject. 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.Deleteobject.- Return type:
- Usage:
To create a
thurible.messages.Deleteobject:import thurible.messages as msgs name = 'alert1' msg = msgs.Delete(name)
- class thurible.messages.Dismiss(name: str = 'alert')[source]¶
Create a new
thurible.messages.Dismissobject. 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.Dismissobject.- Return type:
- Usage:
To create a
thurible.messages.Dismissobject:import thurible.messages as msgs name = 'alert1' msg = msgs.Dismiss(name)
- class thurible.messages.End(text: str = '')[source]¶
Create a new
thurible.messages.Endobject. 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.Endobject.- Return type:
- Usage:
To create a
thurible.messages.Endobject:import thurible.messages as msgs name = 'Goodbye!' msg = msgs.End(name)
- class thurible.messages.Ping(name: str)[source]¶
Create a new
thurible.messages.Pingobject. This object is a command message used to instruct a manager to reply with athurible.message.Pongmessage, proving the manager is still listening for and responding to messages.- Parameters:
name – A unique name used to identify the resulting
thurible.message.Pongmessage as being caused by this message.- Returns:
An
thurible.messages.Pingobject.- Return type:
- Usage:
To create a
thurible.messages.Pingobject:import thurible.messages as msgs name = 'ping1' msg = msgs.Ping(name)
- class thurible.messages.Show(name: str)[source]¶
Create a new
thurible.messages.Showobject. 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.Showobject.- Return type:
- Usage:
To create a
thurible.messages.Showobject:import thurible.messages as msgs name = 'alert1' msg = msgs.Show(name)
- class thurible.messages.Showing(name: str = '')[source]¶
Create a new
thurible.messages.Showingobject. This object is a command message used to instruct a manager to respond with athurible.messages.Shownmessage with the name of the currently displayed panel.- Parameters:
name – (Optional.) A unique name used to identify the resulting
thurible.message.Shownmessage as being caused by this message.- Returns:
An
thurible.messages.Showingobject.- Return type:
- Usage:
To create a
thurible.messages.Showingobject: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.Storeobject. 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.Storeobject.- Return type:
- Usage:
To create a
thurible.messages.Storeobject: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.Storingobject. This object is a command message used to instruct a manager to respond with athurible.message.Storedobject containing the names of the currently stored panels.- Parameters:
name – (Optional.) A unique name used to identify the resulting
thurible.message.Storedmessage as being caused by this message.- Returns:
An
thurible.messages.Storingobject.- Return type:
- Usage:
To create a
thurible.messages.Storingobject:import thurible.messages as msgs name = 'check_stored_displays' msg = msgs.Storing(name)
- class thurible.Update(text: str)[source]¶
Create a new
thurible.log.Updateobject. This object is a command message used to instruct the currently displayedthurible.Logto add the text given in the message.- Parameters:
text – The message to add to the panel.
- Returns:
An
thurible.Updateobject.- Return type:
- Usage:
To create a new
thurible.Updateobject:import thurible update = thurible.Update('spam')
- class thurible.Tick(message: str = '')[source]¶
Create a new
thurible.progress.Tickobject. When sent tothurible.Progress.update(), this will cause the progress bar to advance.- Parameters:
message – A message to display.
- Returns:
A
thurible.Tickobject.- Return type:
- Usage:
To create a message to advance a
thurible.Progressobject 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.NoTickobject. When sent tothurible.Progress.update(), this will not cause the progress bar to advance.- Parameters:
message – A message to display.
- Returns:
A
thurible.NoTickobject.- Return type:
- Usage:
To create a message to advance a
thurible.Progressobject 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.Dataobject. 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.Dataobject.- Return type:
- Usage:
To create a
thurible.messages.Dataobject: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.Endingobject. 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.Endingobject.- Return type:
- Usage:
To create a
thurible.messages.Endingobject: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.Pongobject. This object is a response message used to respond to athurible.messages.Pingmessage.- Parameters:
name – The name of the
thurible.messages.Pingmessage that caused this response.- Returns:
An
thurible.messages.Pongobject.- Return type:
- Usage:
To create a
thurible.messages.Pongobject: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.Shownobject. This object is a response message used to respond to athurible.messages.Showingmessage.- Parameters:
name – The name of the
thurible.messages.Showingmessage that caused this response.display – The name of the panel being displayed when the
thurible.messages.Showingwas received.
- Returns:
An
thurible.messages.Shownobject.- Return type:
- Usage:
To create a
thurible.messages.Shownobject: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.Storedobject. This object is a response message used to respond to athurible.messages.Storingmessage.- Parameters:
name – The name of the
thurible.messages.Storingmessage that caused this response.display – The names of the panel being stored when the
thurible.messages.Storingmessage was received.
- Returns:
An
thurible.messages.Storedobject.- Return type:
- Usage:
To create a
thurible.messages.Storedobject:import thurible.messages as msgs name = 'check_stored_displays' stored = ['alert1', 'text1', 'doc_menu', 'text2',] msg = msgs.Stored(name, stored)