49. gui.dialogs — Specialized dialogs for the pyFormex GUI.

This module provides some dialogs that collect specific input for some pyFormex GUI function. Most of these dialogs are normally accessed from the GUI menus. But the user can also use these in his scripts.

49.1. Classes defined in module gui.dialogs

class gui.dialogs.FileDialog(path='.', filter='*', *, mode='file', compr=False, auto_suffix=True, sidebar=[], add_to_sidebar=False, chdir=False, extra=[], enablers=[], caption='pyFormex File Dialog', **kargs)[source]

A customizable file selection Dialog.

This is a specialized Dialog for the input of one or more file or directory paths. It includes a customized QFileDialog and being subclassed from Dialog, it can be easily further customized to add more input fields.

Parameters:
  • path (path_like) – The initial path displayed in the file selector widget.

  • filter (list of str) – The filters for the files selectable in the file selector widget.

  • mode (str) –

    Determines what can be selected. One of:

    • ’file’: select a file (existing or not). This is the default.

    • ’exist’: select an existing file

    • ’dir’: select an existing directory (widget allows to create a new)

    • ’any’: select a file (existing or not) or a directory

    • ’multi’: select multiple existing paths from the same directory

  • compr (bool) – If True, the specified filters will be expanded to also include compressed files of the specified patterns. Compression algorithms include ‘gz’ and ‘bz2’. For example, a filter ‘Python files (*.py)’ would be changed to ‘Python files (*.py *.py.gz *.py.bz2)’.

  • auto_suffix (bool) – If True (default), new file names will automatically be changed to have an extension matching the current filter. If False, any name is accepted as a new file name.

  • sidebar (list) – A list of path_like strings to add to the sidebar of the file selection widget. This is typically used to provide shortcuts to often used directories.

  • extra (list) – A list of input items to be added to the FileDialog. No input item should be named ‘filename’.

  • kargs – Other keyword parameters to be passed to the Dialog super class.

Returns:

dict – The results dict of the Dialog. If the selection was accepted, this will at least include a key ‘filename’ with the path of the selected file or files or directory. If extra items were specified, there will be keys corresponding to the item names.

See also

GeometryFileDialog

A FileDialog to select a pyFormex Geometry File (PGF)

ProjectDialog

A FileDialog to select a pyFormex Project File (PYF)

ImageSaveDialog

A FileDialog for saving the rendering to an image file

selectFile(fn)[source]

Set the current selection on the file widget

close()[source]

Perform additional actions on close

class gui.dialogs.GeometryFileDialog(path=None, filter='pgf', *, fmode='binary', compression=4, intend=None, convert=True, **kargs)[source]

A file selection dialog specialized for opening .pgf files.

class gui.dialogs.ProjectDialog(path=None, filter='pyf', *, compression=4, protocol=None, access=None, default=None, convert=True, **kargs)[source]

A file selection dialog specialized for opening projects.

class gui.dialogs.SaveImageDialog(path=None, filter=['img', 'icon', 'all'], *, multi=False)[source]

A dialog for saving an image to a file.

This is a specialized Dialog for the input of all data required to save the current pyFormex rendering to an image file. It is a convenient interactive frontend for the image.saveImage() function. The Dialog ask for the target file name and all the other parameters accepted by that function.

Parameters:
  • path (path_like) – The initial path displayed in the file selector widget. See FileDialog.

  • filer (list of str) – The filters for the files selectable in the file selecter widget. See FileDialog.

  • multi (bool) – If True, the dialog will show the multisave option initially checked.

validate()[source]

Update the dialog’s return value from the field values.

This function is connected to the ‘accepted()’ signal. Modal dialogs should normally not need to call it. In non-modal dialogs however, you can call it to update the results without having to raise the accepted() signal (which would close the dialog).

Returns:

bool – True if all fields got validated. As a side effect, self.results will then contain the validated results. If some field failed validation, the corresponding result is set to None, and the return value is False.

class gui.dialogs.RecordSessionDialog(path=None, filter=['video', 'all'])[source]

A dialog for recording the GUI to a video file.

This is a specialized Dialog for the input of all data required to save the current pyFormex rendering to an image file. It is a convenient interactive frontend for the image.saveImage() function. The Dialog ask for the target file name and all the other parameters accepted by that function.

Parameters:
  • path (path_like) – The initial path displayed in the file selector widget. See FileDialog.

  • filer (list of str) – The filters for the files selectable in the file selecter widget. See FileDialog.