65. gui.projectmgr — Project menu.

Menu for handling Project contents and Project files.

65.1. Classes defined in module gui.projectmgr

class gui.projectmgr.ProjectManager(project, fname='public')[source]

Project Manager

closeEvent(self, a0: QCloseEvent)[source]
property selection

Return names of selected objects

property sel_values

Returns selected objects

sel_items()[source]

Returns selected items

sel_dict()[source]

Return a dict with the selected objects

list_all()[source]

Print all Project keys

list_matches()[source]

Print all names passing filter

clear_proj()[source]

Clear the contents of the current project

print_info(info)[source]

Print some info about an object

rename_sel()[source]

Rename selected variables

edit_sel()[source]

Edit a global variable.

set_filter(fname=None, *, clas=None, like=None, func=None)[source]

Set the Project filter and update Project Manager accordingly

ask_sel(fname=None, *, clas=None, like=None, func=None, single=False)[source]

Ask the user to make a selection

Pops up the Project Manager with the provided arguments, lets the user make a selection, and returns the selected object names. Takes all the parameters like Project.contents(). Only the extra parameters are explained below.

Parameters:

single (bool, optional) – If True, only a single object should be selected. The default allows a multiple objects selection.

Returns:

list – The list of selected objects, empty if the dialog was canceled or nothing was selected.

check_sel(*, fname=None, clas=None, like=None, func=None, single=False, warn=True, ask=True)[source]

Check the current selection.

Checks that a current selection exists and conforms to the provided requirements. Takes all the parameters like ask_sel() and the extra ones explained below.

Parameters:
  • warn (bool, optional) – If True (default), a warning is displayed if the selection is empty or there is more than one selected object when single=True was specified. Setting to False suppresses the warning, which may be useful in batch processing.

  • ask (bool, optional) – If True and the selection is not ok, calls ask_sel with the same parameters to let the user adkust the selection. Then runs the check again.

Returns:

bool – True if the selection is not empty and conforms to the provided requirements.

get_sel(**kargs)[source]

Check the current selection and return the selected objects

Parameters are like for check_sel.

Returns:

list | object – If single=True was specified, a single object from the current Project. Else, a list of such objects. The returned list is actually a List instance, so it can directly accept transformations. If nothing was selected, an empty list is returned.

set_sel(values, names=None, suffix=None, fname=None)[source]

Set a new selection specifying names and values, and redraw.

Parameters:
  • values (list) – List of values.

  • names (list, optional) – List of object names, same length as values. If not provided, the current selection is used.

  • suffix (str) – String to append to all names.

  • fname (str) – Filter name to set on the Project.

remember_sel()[source]

Remember the selection

replace_sel(values, remember=False)[source]

Replace the current values of selection by new ones and redraw.

Parameters:
  • values (list) – The new objects to store under the names of the current selection.

  • remember (bool) – If True, the old values are remembered (to enable undo operation), and drawn in yellow.

readGeometry(files, target=None, select=True, draw=True, **kargs)[source]

Read a number of Geometry files, select and draw the results

65.2. Functions defined in module gui.projectmgr

gui.projectmgr.askProjectFilename(fn=None, exist=False, caption='Select Project File')[source]

Ask the user for a Project file.

gui.projectmgr.openProject(fn=None, exist=False, read_only=False)[source]

Open a (new or old) Project file.

Ask the user for a Project file name and open the Project. This loads the project data and sets the selected file as the target for Project save operations. If a Project was already open, it is saved and closed first.

Parameters:

fn (path_like) –

Returns:

Project | None – The opened Project, or None if the user canceled the dialog.

gui.projectmgr.set_project(proj)[source]

Make the specified project the current project.

The current project is thrown away (make sure you have saved it if needed) and the provided project becomes the current project.

Parameters:

proj (Project) – A Project

gui.projectmgr.importProject(fn=None)[source]

Import an existing project.

Ask the user to select an existing project file, and then import all or selected data from it into the current project.

gui.projectmgr.saveAsProject(fn=None)[source]

Save the current project under a new name.

A new project file is created, with the contents of the current project. The new project file becomes the current one.

Returns:

bool – True if the project was saved, False if not (because the user canceled the dialog or didn’t allow overwriting an existing file).

gui.projectmgr.saveProject()[source]

Save the current project.

If the current project has no filename, this is equivalent to saveAsProject(). It the projects has a filename and the contents has changed since the last save, it is saved to that file.

gui.projectmgr.closeProject(save=None, clear=None)[source]

Close the current project, possibly saving it.

After closing, the current project is empty and not connected to a project file.

Parameters:
  • save (bool, optional) – If True or False, determines whether the project should be saved prior to closing it. The default is to ask it from the user if there are unsaved changes in the project and the project is connected to a project file.

  • clear (-) –

gui.projectmgr.objectInfo(obj, info)[source]

Return some info about an object

gui.projectmgr.projectmanager(show=None)[source]

Create/show/hide the Project Manager.

The Project Manager is a persistent object in this module. If it already exists, it is reused. Else, a new one is created and set. It can be hidden or shown.

Parameters:

show (bool, optional) – If True, shows the Project Manager. If False, hides it. If not specified, leaves it as it was (which is shown for a newly created Project Manager is always shown).

Returns:

ProjectManager – The current Project Manager.