UI Module sw.ui

Classes

class sw.ui.Ui(screen, pool)[source]

The UI class houses the curses instance which in turn enables all user-requested actions while displaying relevant information. Only one instance of UI should ever be initialized. Initialization handles all the color constants generation along with defining all subwindows statically.

Parameters:
  • screen – Used with the wrapping function provided by curses. This is a curses screen that has just been created.
  • pool – Reference to our owning pool. This pool will be monitored and displayed on the main status window.
Returns:

UI (self)

drawMainScreen(first=False)[source]

Renders the initial screen and sets up options for curses. Draws the border around the screen and the separators for the various sections with the title.

Parameters:first (False) – Whether this is the call by the UI initialization.
Returns:None
handleCommandKeys(key)[source]

Part of our sleep() function which checks if any of our accepted keys are pressed. It handles the logic for interpreting presses while recording and discarding them. The render of keys in the bottom right of the screen is done by updateKeys().

Parameters:key – The key to process / store. If it’s +/-, the all recorded keys that are relevant are executed.
Returns:None
sleep(amount)[source]

Handles sleeping while listening for button presses. The hardcoded subsleep (0.01s) amount is an appropriate resolution that allows for seemingly instant button press responses without consuming an entire core (when constantly listening).

Parameters:amount – Float for amount of seconds to wait while listening to button presses. This is accurately followed to a resolution of 0.01s.
Returns:None
think()[source]

Calls several other functions which need to be checked constantly. Includes updateStats(), updateKeys(), and updateMain(). The last one is called every time think is, while the other two are called every self.nextUpdate seconds.

Returns:None
toggleKey(key)[source]

Toggles a key display on the right hand side.

Parameters:key – A key that’s listed on the right hand pane to toggle to an alternate option.
Returns:None
updateKeys()[source]

Handles rendering any relevant keys recorded from user input. It reads from self.keys to do this.

Returns:None
updateMain()[source]

Prints out a number for each of our children with an appropriate color for each corresponding with the last status message they reported. Refreshes the screen when done.

Returns:None
updateStats()[source]

Updates the statistics field within our window. Completely clears all of it initally then slowly goes through and reads from each individual pool value to rebuild it. This is called from think() and refreshes several times per second.

Returns:None
x()[source]

Accessor for returning the x size of the curses screen.

Returns:Integer of the number of characters along the x axis of the screen.
y()[source]

Accessor for returning the y size of the curses screen.

Returns:Integer of the number of characters along the y axis of the screen.

Table Of Contents

Previous topic

Formatting Module sw.formatting

Next topic

Reporting Module sw.report

This Page