60. gui.toolbar — Toolbars for the pyFormex GUI.

This module defines the functions for creating the pyFormex window toolbars.

60.1. Classes defined in module gui.toolbar

class gui.toolbar.ViewportToggle(toolbar, icons, attr, checked=False, tooltip='')[source]

A toolbar button that toggles the state of a Viewpor attribute

attr: one of ‘perspective’,

getstate()[source]

Get the current state of the viewport attribute.

setstate(onoff=None)[source]

Toggle the state of the viewport attribute.

60.2. Functions defined in module gui.toolbar

gui.toolbar.pick(mode, *, tool='pix', filter=None, oneshot=False, func=None, pickable=None, prompt=None, _rect=None, minobj=0, **kargs)[source]

Enter interactive picking mode and return selection.

See gui.qtcanvas.Canvas.pick() for more details. This function differs in that it provides an extra interactive interface in the statusbar: OK/Cancel buttons to stop the picking operation, and comboboxes to change the picking tool and filters.

Parameters:
  • mode (str) – Defines what to pick : one of ‘actor’, ‘element’ or ‘point’. ‘actor’ picks complete actors. ‘element’ picks elements from one or more actor(s). ‘point’ picks points of Formices or nodes of Meshes.

  • tool (str) – Defines what picking tool to use. One of ‘pix’, ‘any’ or ‘all’. With ‘pix’ items are picked if they have any visible pixels in the pick rectangle. With ‘any’, items are picked if any of their points are inside the pick rectangle. With ‘all’, items are picked if all their points are inside the rectangle.

  • filter (str) – The picking filter that is activated on entering the pick mode. It should be one of the Canvas.selection_filters: ‘none’, ‘single’, ‘closest’, ‘connected’. The active filter can be changed from a combobox in the statusbar. The available filters depend on the picking tool.

  • oneshot (bool.) – If True, the function returns as soon as the user ends a picking operation. The default is to let the user modify his selection and to return only after an explicit cancel (ESC or right mouse button).

  • func (callable, optional) – If specified, this function will be called after each atomic pick operation. The Collection with the currently selected objects is passed as an argument. This can e.g. be used to highlight the selected objects during picking.

  • pickable (list of Actors, optional) – List of Actors from which can be picked. The default is to use a list with all Actors having the pickable=True attribute (which is the default for newly constructed Actors).

  • prompt (str) – The text printed to prompt the user to start picking. If None, a default prompt is printed. Specify an empty string to avoid printing a prompt.

  • minobj (int) –

Returns:

Collection – A (possibly empty) Collection with the picked items. After return, the value of the pf.canvas.selection_accepted variable can be tested to find how the picking operation was exited: True means accepted (right mouse click, ENTER key, or OK button), False means canceled (ESC key, or Cancel button). In the latter case, the returned Collection is always empty. Ther returned Collection also remains available in pf.canvas.selection until a new pick is started.

gui.toolbar.picksel(obj_type, **kargs)[source]

Pick and print selection

gui.toolbar.query(obj_type, **kargs)[source]

Enter interactive query mode.

Enters a continuous picking mode where the user can pick objects and the picked objects are reported in detail. This is usually called from the toolbar Query buttons. The query mode stays active until the user cancels pick mode (with ESC or right mouse button). distan

Parameters:
  • obj_type (str) – Defines what to pick : one of ‘actor’, ‘element’ or ‘point’

  • **kargs – Extra parameters to be passed to pick()

gui.toolbar.query_distance(colorid=0, colorstep=1, show=True, prec=None)[source]

Enter interactive distance query mode

In distance query mode, the user picks subsequent single points. For every second point picked, the distance to the previous point is shown. The distances are shown and printed with subsequent colors from the canvas default colormap or from a custom colormap in pf.cfg[‘draw/querypalette’].

gui.toolbar.query_angle(colorid=0, colorstep=1, show=True, prec=None)[source]

Enter interactive angle query mode

In angle query mode, the user picks subsequent single points. For every third point picked, the angle between the vectors from first to second and from secont to third is shown. The angles are shown and printed with subsequent colors from the canvas default colormap or from a custom colormap in pf.cfg[‘draw/querypalette’].

gui.toolbar.addButton(toolbar, tooltip, icon, func, repeat=False, toggle=False, checked=False, icon0=None, enabled=True)[source]

Add a button to a toolbar.

  • toolbar: the toolbar where the button will be added

  • tooltip: the text to appear as tooltip

  • icon: name of the icon to be displayed on the button,

  • func: function to be called when the button is pressed,

  • repeat: if True, the func will repeatedly be called if button is held down.

  • toggle: if True, the button is a toggle and stays in depressed state until pressed again.

  • checked: initial state for a toggle buton.

  • icon1: for a toggle button, icon to display when button is not checked.

gui.toolbar.removeButton(toolbar, button)[source]

Remove a button from a toolbar.

gui.toolbar.addActionButtons(toolbar)[source]

Add the script action buttons to the toolbar.

gui.toolbar.addCameraButtons(toolbar)[source]

Add the camera buttons to a toolbar.

gui.toolbar.updateWireButton()[source]

Update the wire button to correct state.

gui.toolbar.updateTransparencyButton()[source]

Update the transparency button to correct state.

gui.toolbar.updateLightButton()[source]

Update the light button to correct state.

gui.toolbar.updateNormalsButton()[source]

Update the normals button to correct state.

gui.toolbar.updatePerspectiveButton()[source]

Update the perspective button to correct state.

gui.toolbar.addTimeoutButton(toolbar)[source]

Add or remove the timeout button,depending on cfg.

gui.toolbar.timeout(onoff=None)[source]

Programmatically toggle the timeout button