item#
Item is the basic building block of the terminal UI. It represents a single
selectable item in the dropdown menu. User can move or scroll selector up and down
to select an item, and then perform action.
- class zelfred.item.Item(title: str, subtitle: ~typing.Optional[str] = None, uid: str = <factory>, arg: ~typing.Optional[str] = None, autocomplete: ~typing.Optional[str] = None, variables: ~typing.Dict[str, ~typing.Any] = <factory>)[source]#
Represent an item in the terminal UI. In the example below, the
[x] Beautiful is better than uglyandsubtitle 01is one item.(Query): [x] Beautiful is better than ugly. subtitle 01 [ ] Explicit is better than implicit. subtitle 02 [ ] Simple is better than complex. subtitle 03
- Parameters:
uid – item unique id. The UI use this to distinguish different items.
title – first line of the item. It has a checkbox in front of it to indicate whether it is selected.
subtitle – second line of the item.
arg – argument that will be passed to the action.
autocomplete – the text that will be filled in the input box when user hits
TABkey.variables – arbitrary dictionary object, it can be used in the action.
- enter_handler(ui: UI)[source]#
This is the abstract method that will perform user defined action when user hits
Enteron this item. Develop should inherit this class and override this method to perform user defined action.- Parameters:
ui – the
UIobject.
- post_enter_handler(ui: UI)[source]#
This is the abstract method that will update the UI after taking user action.
- Parameters:
ui – the
UIobject.
- ctrl_a_handler(ui: UI)[source]#
This is the abstract method that will perform user defined action when user hits
Ctrl + Aon this item. Develop should inherit this class and override this method to perform user defined action.- Parameters:
ui – the
UIobject.
- post_ctrl_a_handler(ui: UI)[source]#
This is the abstract method that will update the UI after taking user action.
- Parameters:
ui – the
UIobject.
- ctrl_w_handler(ui: UI)[source]#
This is the abstract method that will perform user defined action when user hits
Ctrl + Won this item. Develop should inherit this class and override this method to perform user defined action.- Parameters:
ui – the
UIobject.
- post_ctrl_w_handler(ui: UI)[source]#
This is the abstract method that will update the UI after taking user action.
- Parameters:
ui – the
UIobject.
- ctrl_u_handler(ui: UI)[source]#
This is the abstract method that will perform user defined action when user hits
Ctrl + Uon this item. Develop should inherit this class and override this method to perform user defined action.- Parameters:
ui – the
UIobject.
- post_ctrl_u_handler(ui: UI)[source]#
This is the abstract method that will update the UI after taking user action.
- Parameters:
ui – the
UIobject.