pycrossword  0.3
Pure-Python implementation of a crossword puzzle generator and editor
Public Member Functions | Public Attributes | Private Member Functions | List of all members
pycross.forms.ToolbarCustomizer Class Reference

Toolbar customizer widget (incorporated by SettingsDialog). More...

Inheritance diagram for pycross.forms.ToolbarCustomizer:

Public Member Functions

def __init__ (self, action_source, toolbar, parent=None)
 Constructor. More...
 
def addMainLayout (self)
 Creates the main layout for controls. More...
 
def update_actions (self)
 Enables or disables actions depending on the selection of source and target buttons. More...
 
def update_src_actions (self)
 Disables elements in the source action treeview which are already added to the target list view. More...
 
def reset (self)
 Resets (reloads) source and target actions from the source toolbar. More...
 
def update_added (self, actions, clear=True)
 Reloads the right-hand actions (list view) from an action source. More...
 
def add_src_action (self, action, tree_item=None)
 Adds a source action to the left-hand treeview. More...
 
def from_list (self, act_list)
 Initializes added actions from a list of action names as in CWSettings['gui']['toolbar_actions']. More...
 
def to_list (self)
 Serializes the added actions into a flat list of actions and 'SEP' (separators). More...
 
def on_act_add (self)
 Adds selected action(s) to the target list. More...
 
def on_act_addsep (self)
 Adds a separator after the selected action. More...
 
def on_act_remove (self)
 Removes the selected action from the target list. More...
 
def on_act_clear (self)
 Clears all added actions. More...
 
def on_act_up (self)
 Moves selected action up. More...
 
def on_act_down (self)
 Moves selected action down. More...
 
def on_tw_actions_selected (self)
 Updates available actions when the selection changes. More...
 

Public Attributes

 action_source
 QtWidgets.QActionGroup | QtWidgets.QMenu | QtWidgets.QAction source for actions The source actions will be shown on the left-hand panel (ToolbarCustomizer::tw_actions) More...
 
 src_toolbar
 QtWidgets.QToolBar the initial (source) toolbar that must be configured All buttons (actions) already present in the toolbar will be shown on the right-hand panel (ToolbarCustomizer::lw_added) More...
 
 src_actions
 list of source actions More...
 
 layout_controls
 
 splitter1
 
 tw_actions
 QtWidgets.QTreeWidget source actions (buttons) that can be added to the toolbar More...
 
 layout_right
 
 tb
 
 act_add
 
 act_remove
 
 act_addsep
 
 act_clear
 
 act_up
 
 act_down
 
 layout_preview
 
 l_added
 
 lw_added
 QtWidgets.QListWidget target actions (buttons) and separators to be shown in the toolbar More...
 
 w_layout_right
 

Private Member Functions

def _lw_add (self, lw, item, row=-1)
 Util function: adds a new item to a QListWidget control. More...
 

Detailed Description

Toolbar customizer widget (incorporated by SettingsDialog).

This widget provides the user with a handy tool to tweak a toolbar (in this app only the main toolbar is customizable) by adding / removing buttons / separators and changing their order.

Todo:
implement Drag And Drop from treeview to list / toolbar – see example

Constructor & Destructor Documentation

◆ __init__()

def pycross.forms.ToolbarCustomizer.__init__ (   self,
  action_source,
  toolbar,
  parent = None 
)

Constructor.

Parameters
action_sourceQtWidgets.QActionGroup | QtWidgets.QMenu | QtWidgets.QAction source for actions added as toolbar buttons – either an action group or a menu, or a single action
toolbarQtWidgets.QToolBar the initial (source) toolbar that must be configured (each of which may have child actions)
parentQtWidgets.QWidget parent widget

Member Function Documentation

◆ _lw_add()

def pycross.forms.ToolbarCustomizer._lw_add (   self,
  lw,
  item,
  row = -1 
)
private

Util function: adds a new item to a QListWidget control.

◆ add_src_action()

def pycross.forms.ToolbarCustomizer.add_src_action (   self,
  action,
  tree_item = None 
)

Adds a source action to the left-hand treeview.

Parameters
actionQtWidgets.QActionGroup | QtWidgets.QMenu | QtWidgets.QAction source for actions added as toolbar buttons – either an action group or a menu, or a single action (each of which may have child actions)
tree_itemQtWidgets.QTreeWidgetItem | None tree widget item to add the action(s) to: if None, actions will be added as root nodes, otherwise they will be the children of 'tree_item'
Returns
QtWidgets.QTreeWidgetItem the added tree widget item

◆ addMainLayout()

def pycross.forms.ToolbarCustomizer.addMainLayout (   self)

Creates the main layout for controls.

◆ from_list()

def pycross.forms.ToolbarCustomizer.from_list (   self,
  act_list 
)

Initializes added actions from a list of action names as in CWSettings['gui']['toolbar_actions'].

Parameters
act_listiterable collection (e.g. list) of actions and 'SEP' (separators)
See also
ToolbarCustomizer::to_list()

◆ on_act_add()

def pycross.forms.ToolbarCustomizer.on_act_add (   self)

Adds selected action(s) to the target list.

◆ on_act_addsep()

def pycross.forms.ToolbarCustomizer.on_act_addsep (   self)

Adds a separator after the selected action.

◆ on_act_clear()

def pycross.forms.ToolbarCustomizer.on_act_clear (   self)

Clears all added actions.

◆ on_act_down()

def pycross.forms.ToolbarCustomizer.on_act_down (   self)

Moves selected action down.

◆ on_act_remove()

def pycross.forms.ToolbarCustomizer.on_act_remove (   self)

Removes the selected action from the target list.

◆ on_act_up()

def pycross.forms.ToolbarCustomizer.on_act_up (   self)

Moves selected action up.

◆ on_tw_actions_selected()

def pycross.forms.ToolbarCustomizer.on_tw_actions_selected (   self)

Updates available actions when the selection changes.

◆ reset()

def pycross.forms.ToolbarCustomizer.reset (   self)

Resets (reloads) source and target actions from the source toolbar.

◆ to_list()

def pycross.forms.ToolbarCustomizer.to_list (   self)

Serializes the added actions into a flat list of actions and 'SEP' (separators).

Returns
list list of actions and 'SEP' (separators)
See also
ToolbarCustomizer::from_list()

◆ update_actions()

def pycross.forms.ToolbarCustomizer.update_actions (   self)

Enables or disables actions depending on the selection of source and target buttons.

◆ update_added()

def pycross.forms.ToolbarCustomizer.update_added (   self,
  actions,
  clear = True 
)

Reloads the right-hand actions (list view) from an action source.

Parameters
actionsiterable collection of source actions (each of type QtWidgets.QAction)
clearbool whether to clear the existing items (actions) before adding new ones

◆ update_src_actions()

def pycross.forms.ToolbarCustomizer.update_src_actions (   self)

Disables elements in the source action treeview which are already added to the target list view.

Member Data Documentation

◆ act_add

pycross.forms.ToolbarCustomizer.act_add

◆ act_addsep

pycross.forms.ToolbarCustomizer.act_addsep

◆ act_clear

pycross.forms.ToolbarCustomizer.act_clear

◆ act_down

pycross.forms.ToolbarCustomizer.act_down

◆ act_remove

pycross.forms.ToolbarCustomizer.act_remove

◆ act_up

pycross.forms.ToolbarCustomizer.act_up

◆ action_source

pycross.forms.ToolbarCustomizer.action_source

QtWidgets.QActionGroup | QtWidgets.QMenu | QtWidgets.QAction source for actions The source actions will be shown on the left-hand panel (ToolbarCustomizer::tw_actions)

◆ l_added

pycross.forms.ToolbarCustomizer.l_added

◆ layout_controls

pycross.forms.ToolbarCustomizer.layout_controls

◆ layout_preview

pycross.forms.ToolbarCustomizer.layout_preview

◆ layout_right

pycross.forms.ToolbarCustomizer.layout_right

◆ lw_added

pycross.forms.ToolbarCustomizer.lw_added

QtWidgets.QListWidget target actions (buttons) and separators to be shown in the toolbar

◆ splitter1

pycross.forms.ToolbarCustomizer.splitter1

◆ src_actions

pycross.forms.ToolbarCustomizer.src_actions

list of source actions

◆ src_toolbar

pycross.forms.ToolbarCustomizer.src_toolbar

QtWidgets.QToolBar the initial (source) toolbar that must be configured All buttons (actions) already present in the toolbar will be shown on the right-hand panel (ToolbarCustomizer::lw_added)

◆ tb

pycross.forms.ToolbarCustomizer.tb

◆ tw_actions

pycross.forms.ToolbarCustomizer.tw_actions

QtWidgets.QTreeWidget source actions (buttons) that can be added to the toolbar

◆ w_layout_right

pycross.forms.ToolbarCustomizer.w_layout_right

The documentation for this class was generated from the following file: