Package entropy :: Module output :: Class TextInterface

Class TextInterface

source code


TextInterface is a base class for handling the communication between user and Entropy-based applications.

This class works for text-based applications, it must be inherited from subclasses and its methods reimplemented to make Entropy working on situations where a terminal is not used as UI (Graphical applications, web-based interfaces, remote interfaces, etc).

Every part of Entropy is using the methods in this class to communicate with the user, channel is bi-directional.

Instance Methods
None
updateProgress(self, text, header='', footer='', back=False, importance=0, type='info', count=None, percent=False)
Text output print function.
source code
None
askQuestion(self, question, importance=0, responses=None)
Questions asking function.
source code
 
inputBox(self, title, input_parameters, cancel_button=True)
Generic input box (form) creator and data collector.
source code
 
cycleDone(self)
Not actually implemented.
source code
 
setTitle(self, title)
Set application title.
source code
 
setTotalCycles(self, total)
Not actually implemented.
source code
 
nocolor(self)
Disable coloured output.
source code
 
notitles(self)
Disable the ability to effectively set the application title.
source code
Method Details

updateProgress(self, text, header='', footer='', back=False, importance=0, type='info', count=None, percent=False)

source code 

Text output print function. By default text is written to stdout.

Parameters:
  • text (string) - text to write to stdout
  • header (string) - text header (decoration?)
  • footer (string) - text footer (decoration?)
  • back (bool) - push back cursor to the beginning of the line
  • importance (int) - message importance (default valid values: 0, 1, 2, 3
  • type (string) - message type (default valid values: "info", "warning", "error")
  • count (tuple) - tuple of lengh 2, containing count information to make function print something like "(10/100) doing stuff". In this case tuple would be: (10, 100,)
  • percent - determine whether "count" argument should be printed as percentual value (for values like (10, 100,), "(10%) doing stuff" will be printed.
  • percent - bool
Returns: None
None

askQuestion(self, question, importance=0, responses=None)

source code 

Questions asking function. It asks the user to answer the question given by choosing between a preset list of answers given by the "reposonses" argument.

Parameters:
  • question (string) - question text
  • importance (int) - question importance (no default valid values)
  • responses (tuple or list) - list of valid answers which user has to choose from
Returns: None
None

inputBox(self, title, input_parameters, cancel_button=True)

source code 

Generic input box (form) creator and data collector.

@param title: input box title
@type title: string
@param input_parameters: list of properly formatted tuple items.
@type input_parameters: list
@keyword cancel_button: make possible to "cancel" the input request.
@type cancel_button: bool
@return: dict containing input box answers
@rtype: dict

input_parameters supported items:

[input id], [input text title], [input verification callback], [
    no text echo?]
('identifier 1', 'input text 1', input_verification_callback, False)

('item_3', ('checkbox', 'Checkbox option (boolean request) - please choose',),
    input_verification_callback, True)

('item_4', ('combo', ('Select your favorite option', ['option 1', 'option 2', 'option 3']),),
    input_verification_callback, True)

('item_4',('list',('Setup your list',['default list item 1', 'default list item 2']),),
    input_verification_callback, True)

cycleDone(self)

source code 

Not actually implemented. Can be useful for external applications and its used to determine when a certain transaction is done.

setTitle(self, title)

source code 

Set application title.

Parameters:
  • title (string) - new application title

setTotalCycles(self, total)

source code 

Not actually implemented. Can be useful for external applications and its used to set the amount of logical transactions that this interface has to go through.

nocolor(self)

source code 

Disable coloured output. Used for terminals.