deluge.ui.console.widgets package

Submodules

deluge.ui.console.widgets.fields module

class deluge.ui.console.widgets.fields.BaseField(parent=None, name=None, selectable=True, **kwargs)

Bases: InputKeyHandler

build_fmt_string(focused, active, value_key='msg', **kwargs)
depend_skip()
get_fmt_keys(focused, active, **kwargs)
get_value()
handle_read(c)

Handle a character read from curses screen

Returns:

int – One of the constants defined in util.curses_util.ReadState. ReadState.IGNORED: The key was not handled. Further processing should continue. ReadState.READ: The key was read and processed. Do no further processing ReadState.CHANGED: The key was read and processed. Internal state was changed leaving data to be read by the caller.

has_input()
property height
render(screen, row, **kwargs)
selectable()
set_fmt_key(key, default, kwargsdict=None)
set_value(value)
class deluge.ui.console.widgets.fields.CheckedInput(parent, name, message, checked=False, checked_char='X', unchecked_char=' ', checkbox_format='[%s] ', **kwargs)

Bases: InputField

build_msg_string(focused, active)
property checked
get_fmt_keys(focused, active, **kwargs)
handle_read(c)

Handle a character read from curses screen

Returns:

int – One of the constants defined in util.curses_util.ReadState. ReadState.IGNORED: The key was not handled. Further processing should continue. ReadState.READ: The key was read and processed. Do no further processing ReadState.CHANGED: The key was read and processed. Internal state was changed leaving data to be read by the caller.

render(screen, row, col=0, **kwargs)
set_message(msg)
class deluge.ui.console.widgets.fields.CheckedPlusInput(parent, name, message, child, child_always_visible=False, show_usage_hints=True, msg_fmt='%s ', **kwargs)

Bases: CheckedInput

get_child()
handle_read(c)

Handle a character read from curses screen

Returns:

int – One of the constants defined in util.curses_util.ReadState. ReadState.IGNORED: The key was not handled. Further processing should continue. ReadState.READ: The key was read and processed. Do no further processing ReadState.CHANGED: The key was read and processed. Internal state was changed leaving data to be read by the caller.

property height
render(screen, row, width=None, active=False, focused=False, col=0, **kwargs)
class deluge.ui.console.widgets.fields.ComboInput(parent, name, message, choices, default=None, searchable=True, **kwargs)

Bases: InputField

handle_read(c)

Handle a character read from curses screen

Returns:

int – One of the constants defined in util.curses_util.ReadState. ReadState.IGNORED: The key was not handled. Further processing should continue. ReadState.READ: The key was read and processed. Do no further processing ReadState.CHANGED: The key was read and processed. Internal state was changed leaving data to be read by the caller.

render(screen, row, col=0, **kwargs)
set_value(val)
class deluge.ui.console.widgets.fields.DividerField(parent, name, value, selectable=False, fill_width=True, value_fmt='%s', **kwargs)

Bases: NoInputField

render(screen, row, active=False, focused=False, col=0, width=None, **kwargs)
set_value(value)
class deluge.ui.console.widgets.fields.FloatSpinInput(parent, message, name, move_func, value, precision=1, **kwargs)

Bases: IntSpinInput

handle_read(c)

Handle a character read from curses screen

Returns:

int – One of the constants defined in util.curses_util.ReadState. ReadState.IGNORED: The key was not handled. Further processing should continue. ReadState.READ: The key was read and processed. Do no further processing ReadState.CHANGED: The key was read and processed. Internal state was changed leaving data to be read by the caller.

class deluge.ui.console.widgets.fields.Header(parent, header, space_above, space_below, **kwargs)

Bases: NoInputField

property height
render(screen, row, col=0, **kwargs)
class deluge.ui.console.widgets.fields.InfoField(parent, name, label, value, **kwargs)

Bases: NoInputField

render(screen, row, col=0, **kwargs)
set_value(v)
class deluge.ui.console.widgets.fields.InputField(parent, name, message, format_default=None, **kwargs)

Bases: BaseField

depend = None
depend_skip()
handle_read(c)

Handle a character read from curses screen

Returns:

int – One of the constants defined in util.curses_util.ReadState. ReadState.IGNORED: The key was not handled. Further processing should continue. ReadState.READ: The key was read and processed. Do no further processing ReadState.CHANGED: The key was read and processed. Internal state was changed leaving data to be read by the caller.

set_depend(i, inverse=False)
set_message(msg)
class deluge.ui.console.widgets.fields.IntSpinInput(parent, name, message, move_func, value, min_val=None, max_val=None, inc_amt=1, incr_large=10, strict_validation=False, fmt='%d', **kwargs)

Bases: InputField

handle_read(c)

Handle a character read from curses screen

Returns:

int – One of the constants defined in util.curses_util.ReadState. ReadState.IGNORED: The key was not handled. Further processing should continue. ReadState.READ: The key was read and processed. Do no further processing ReadState.CHANGED: The key was read and processed. Internal state was changed leaving data to be read by the caller.

render(screen, row, active=False, focused=True, col=0, cursor_offset=0, **kwargs)
set_value(val, cursor=True, validate=False, cursor_on_fail=False, value_on_fail=None, on_invalid=None)
validate_value(value, on_invalid=None)
class deluge.ui.console.widgets.fields.NoInputField(parent=None, name=None, selectable=True, **kwargs)

Bases: BaseField

has_input()
class deluge.ui.console.widgets.fields.SelectInput(parent, name, message, opts, vals, active_index, active_default=False, require_select_action=True, **kwargs)

Bases: InputField

get_fmt_keys(focused, active, selected=False, **kwargs)
get_value()
handle_read(c)

Handle a character read from curses screen

Returns:

int – One of the constants defined in util.curses_util.ReadState. ReadState.IGNORED: The key was not handled. Further processing should continue. ReadState.READ: The key was read and processed. Do no further processing ReadState.CHANGED: The key was read and processed. Internal state was changed leaving data to be read by the caller.

property height
render(screen, row, active=False, focused=True, col=0, **kwargs)
set_value(value)
class deluge.ui.console.widgets.fields.TextArea(parent, name, value, value_fmt='%s', **kwargs)

Bases: TextField

has_input()
property height
render(screen, row, col=0, **kwargs)
class deluge.ui.console.widgets.fields.TextField(parent, name, value, selectable=True, value_fmt='%s', **kwargs)

Bases: BaseField

has_input()
render(screen, row, active=False, focused=False, col=0, **kwargs)
set_value(value)
class deluge.ui.console.widgets.fields.TextInput(parent, name, message, move_func, width, value, complete=False, activate_input=False, **kwargs)

Bases: InputField

calculate_cursor_pos(width, col)
calculate_textfield_value(width, cursor_offset)
do_complete(line)
handle_read(c)

Return False when key was swallowed, i.e. we recognised the key and no further action by other components should be performed.

property height
render(screen, row, width=None, active=False, focused=True, col=0, cursor_offset=0, **kwargs)
set_value(val)
property width

deluge.ui.console.widgets.inputpane module

class deluge.ui.console.widgets.inputpane.BaseInputPane(mode, allow_rearrange=False, immediate_action=False, set_first_input_active=True, border_off_west=0, border_off_north=0, border_off_east=0, border_off_south=0, active_wrap=False, **kwargs)

Bases: InputKeyHandler

add_checked_input(name, message, checked=False, col='+1', **kwargs)
add_checkedplus_input(name, message, child, checked=False, col='+1', **kwargs)
add_combo_input(name, message, choices, col='+1', **kwargs)
add_divider_field(name, message, **kwargs)
add_float_spin_input(name, message, value=0.0, col='+1', **kwargs)
add_header(header, space_above=False, space_below=False, **kwargs)
add_info_field(name, label, value)
add_int_spin_input(name, message, value=0, col='+1', **kwargs)
add_select_input(name, message, opts, vals, default_index=0, **kwargs)
add_spaces(num)
add_text(string)
add_text_area(name, message, **kwargs)
add_text_field(name, message, selectable=True, col='+1', **kwargs)
add_text_input(name, message, value='', col='+1', **kwargs)

Add a text input field

Parameters:
  • message – string to display above the input field

  • name – name of the field, for the return callback

  • value – initial value of the field

  • complete – should completion be run when tab is hit and this field is active

ensure_active_visible()
get_content_height()
get_input(name)
get_values()
handle_read(c)

Handle a character read from curses screen

Returns:

int – One of the constants defined in util.curses_util.ReadState. ReadState.IGNORED: The key was not handled. Further processing should continue. ReadState.READ: The key was read and processed. Do no further processing ReadState.CHANGED: The key was read and processed. Internal state was changed leaving data to be read by the caller.

immediate_action_cb(state_changed=True)
move(r, c)
move_active(direction, amount)

direction == -1: Up direction == 1: Down

move_active_down(amount)
move_active_up(amount)
render_inputs(focused=False)
property visible_content_pane_width

deluge.ui.console.widgets.popup module

class deluge.ui.console.widgets.popup.ALIGN

Bases: object

BOTTOM_CENTER = 8
BOTTOM_LEFT = 7
BOTTOM_RIGHT = 9
DEFAULT = 5
MIDDLE_CENTER = 5
MIDDLE_LEFT = 4
MIDDLE_RIGHT = 6
TOP_CENTER = 2
TOP_LEFT = 1
TOP_RIGHT = 3
class deluge.ui.console.widgets.popup.InputPopup(parent_mode, title, **kwargs)

Bases: Popup, BaseInputPane

handle_read(c)

Handle a character read from curses screen

Returns:

int – One of the constants defined in util.curses_util.ReadState. ReadState.IGNORED: The key was not handled. Further processing should continue. ReadState.READ: The key was read and processed. Do no further processing ReadState.CHANGED: The key was read and processed. Internal state was changed leaving data to be read by the caller.

immediate_action_cb(state_changed=True)
class deluge.ui.console.widgets.popup.MessagePopup(parent_mode, title, message, align=5, height_req=0.75, width_req=0.5, **kwargs)

Bases: Popup, BaseInputPane

Popup that just displays a message

handle_read(c)

Handle a character read from curses screen

Returns:

int – One of the constants defined in util.curses_util.ReadState. ReadState.IGNORED: The key was not handled. Further processing should continue. ReadState.READ: The key was read and processed. Do no further processing ReadState.CHANGED: The key was read and processed. Internal state was changed leaving data to be read by the caller.

class deluge.ui.console.widgets.popup.Popup(parent_mode, title, width_req=0, height_req=0, align=5, close_cb=None, encoding=None, base_popup=None, **kwargs)

Bases: BaseWindow, InputKeyHandler

__init__(parent_mode, title, width_req=0, height_req=0, align=5, close_cb=None, encoding=None, base_popup=None, **kwargs)

Init a new popup. The default constructor will handle sizing and borders and the like.

Parameters:
  • parent_mode (basemode subclass) – The mode which the popup will be drawn over

  • title (str) – the title of the popup window

  • width_req (int or float) – An integer value will be used as the width of the popup in character. A float value will indicate the requested ratio in relation to the parents screen width.

  • height_req (int or float) – An integer value will be used as the height of the popup in character. A float value will indicate the requested ratio in relation to the parents screen height.

  • align (ALIGN) – The alignment controlling the position of the popup on the screen.

  • close_cb (func) – Function to be called when the popup is closed

  • encoding (str) – The terminal encoding

  • base_popup (Popup) – A popup used to inherit width_req and height_req if not explicitly specified.

Note: The parent mode is responsible for calling refresh on any popups it wants to show.

This should be called as the last thing in the parents refresh method.

The parent must also call read_input on the popup instead of/in addition to running its own read_input code if it wants to have the popup handle user input.

Popups have two methods that must be implemented:

refresh(self) - draw the popup window to screen. this default mode simply draws a bordered window

with the supplied title to the screen

read_input(self) - handle user input to the popup.

calculate_size()
close(*args, **kwargs)
closed()
handle_read(c)

Handle a character read from curses screen

Returns:

int – One of the constants defined in util.curses_util.ReadState. ReadState.IGNORED: The key was not handled. Further processing should continue. ReadState.READ: The key was read and processed. Do no further processing ReadState.CHANGED: The key was read and processed. Internal state was changed leaving data to be read by the caller.

handle_resize()
refresh()
class deluge.ui.console.widgets.popup.PopupsHandler

Bases: object

pop_popup()
property popup
push_popup(pu, clear=False)
report_message(title, message)
class deluge.ui.console.widgets.popup.SelectablePopup(parent_mode, title, selection_cb, close_cb=None, input_cb=None, allow_rearrange=False, immediate_action=False, **kwargs)

Bases: BaseInputPane, Popup

A popup which will let the user select from some of the lines that are added.

__init__(parent_mode, title, selection_cb, close_cb=None, input_cb=None, allow_rearrange=False, immediate_action=False, **kwargs)
Parameters:
  • parent_mode (basemode subclass) – The mode which the popup will be drawn over

  • title (str) – the title of the popup window

  • selection_cb (func) – Function to be called on selection

  • close_cb (func, optional) – Function to be called when the popup is closed

  • input_cb (func, optional) – Function to be called on every keyboard input

  • allow_rearrange (bool) – Allow rearranging the selectable value

  • immediate_action (bool) – If immediate_action_cb should be called for every action

  • kwargs (dict) – Arguments passed to Popup

add_divider(message=None, char='-', fill_width=True, color='white')
add_line(name, string, use_underline=True, cb_arg=None, foreground=None, selectable=True, selected=False, **kwargs)
current_selection()

Returns a tuple of (selected index, selected data).

handle_read(c)

Handle a character read from curses screen

Returns:

int – One of the constants defined in util.curses_util.ReadState. ReadState.IGNORED: The key was not handled. Further processing should continue. ReadState.READ: The key was read and processed. Do no further processing ReadState.CHANGED: The key was read and processed. Internal state was changed leaving data to be read by the caller.

set_selection(index)

Set a selected index

property visible_content_pane_height

We want to use the Popup property

deluge.ui.console.widgets.sidebar module

class deluge.ui.console.widgets.sidebar.Sidebar(torrentlist, width, height, title=None, allow_resize=False, **kwargs)

Bases: BaseInputPane, BaseWindow

Base sidebar widget that handles choosing a selected widget with Up/Down arrows.

Shows the different states of the torrents and allows to filter the torrents based on state.

add_string(row, string, scr=None, **kwargs)
handle_read(c)

Handle a character read from curses screen

Returns:

int – One of the constants defined in util.curses_util.ReadState. ReadState.IGNORED: The key was not handled. Further processing should continue. ReadState.READ: The key was read and processed. Do no further processing ReadState.CHANGED: The key was read and processed. Internal state was changed leaving data to be read by the caller.

has_focus()
on_resize(width)
refresh()
set_focused(focused)

deluge.ui.console.widgets.statusbars module

class deluge.ui.console.widgets.statusbars.StatusBars

Bases: Component

start()
update()
update_statusbars()

deluge.ui.console.widgets.window module

class deluge.ui.console.widgets.window.BaseWindow(title, width, height, posy=0, posx=0, encoding=None)

Bases: object

BaseWindow creates a curses screen to be used for showing panels and popup dialogs

__init__(title, width, height, posy=0, posx=0, encoding=None)
Parameters:
  • title (str) – The title of the panel

  • width (int) – Width of the panel

  • height (int) – Height of the panel

  • posy (int) – Position of the panel’s first row relative to the terminal screen

  • posx (int) – Position of the panel’s first column relative to the terminal screen

  • encoding (str) – Terminal encoding

add_string(row, string, scr=None, **kwargs)
draw_scroll_indicator(screen)
ensure_content_pane_height(height)
getmaxyx()
property height
hidden()
hide()
move_window(posy, posx)
refresh()
resize_window(rows, cols)
set_title(title)
show()
property visible_content_pane_height
property visible_content_pane_size
property visible_content_pane_width
property width

Module contents

class deluge.ui.console.widgets.BaseInputPane(mode, allow_rearrange=False, immediate_action=False, set_first_input_active=True, border_off_west=0, border_off_north=0, border_off_east=0, border_off_south=0, active_wrap=False, **kwargs)

Bases: InputKeyHandler

add_checked_input(name, message, checked=False, col='+1', **kwargs)
add_checkedplus_input(name, message, child, checked=False, col='+1', **kwargs)
add_combo_input(name, message, choices, col='+1', **kwargs)
add_divider_field(name, message, **kwargs)
add_float_spin_input(name, message, value=0.0, col='+1', **kwargs)
add_header(header, space_above=False, space_below=False, **kwargs)
add_info_field(name, label, value)
add_int_spin_input(name, message, value=0, col='+1', **kwargs)
add_select_input(name, message, opts, vals, default_index=0, **kwargs)
add_spaces(num)
add_text(string)
add_text_area(name, message, **kwargs)
add_text_field(name, message, selectable=True, col='+1', **kwargs)
add_text_input(name, message, value='', col='+1', **kwargs)

Add a text input field

Parameters:
  • message – string to display above the input field

  • name – name of the field, for the return callback

  • value – initial value of the field

  • complete – should completion be run when tab is hit and this field is active

ensure_active_visible()
get_content_height()
get_input(name)
get_values()
handle_read(c)

Handle a character read from curses screen

Returns:

int – One of the constants defined in util.curses_util.ReadState. ReadState.IGNORED: The key was not handled. Further processing should continue. ReadState.READ: The key was read and processed. Do no further processing ReadState.CHANGED: The key was read and processed. Internal state was changed leaving data to be read by the caller.

immediate_action_cb(state_changed=True)
move(r, c)
move_active(direction, amount)

direction == -1: Up direction == 1: Down

move_active_down(amount)
move_active_up(amount)
render_inputs(focused=False)
property visible_content_pane_width
class deluge.ui.console.widgets.BaseWindow(title, width, height, posy=0, posx=0, encoding=None)

Bases: object

BaseWindow creates a curses screen to be used for showing panels and popup dialogs

__init__(title, width, height, posy=0, posx=0, encoding=None)
Parameters:
  • title (str) – The title of the panel

  • width (int) – Width of the panel

  • height (int) – Height of the panel

  • posy (int) – Position of the panel’s first row relative to the terminal screen

  • posx (int) – Position of the panel’s first column relative to the terminal screen

  • encoding (str) – Terminal encoding

add_string(row, string, scr=None, **kwargs)
draw_scroll_indicator(screen)
ensure_content_pane_height(height)
getmaxyx()
property height
hidden()
hide()
move_window(posy, posx)
refresh()
resize_window(rows, cols)
set_title(title)
show()
property visible_content_pane_height
property visible_content_pane_size
property visible_content_pane_width
property width
class deluge.ui.console.widgets.StatusBars

Bases: Component

start()
update()
update_statusbars()