butterfly_viewer.aux_functions

Functions without a specific category for Butterfly Viewer and Registrator.

Not intended as a script.

Credits:

PyQt MDI Image Viewer by tpgit (http://tpgit.github.io/MDIImageViewer/) for sync pan and zoom.

 1#!/usr/bin/env python3
 2
 3"""Functions without a specific category for Butterfly Viewer and Registrator.
 4
 5Not intended as a script.
 6
 7Credits:
 8    PyQt MDI Image Viewer by tpgit (http://tpgit.github.io/MDIImageViewer/) for sync pan and zoom.
 9"""
10# SPDX-License-Identifier: GPL-3.0-or-later
11
12
13
14from PyQt5 import QtCore
15
16
17
18def strippedName(fullFilename):
19    """Get filename from a filepath.
20
21    Legacy function from PyQt MDI Image Viewer by tpgit.
22
23    Args:
24        fullFilename (str): The filepath (the "full" filename).
25    
26    Returns:
27        value (str): The filename as stripped from the filepath.
28    """
29    return QtCore.QFileInfo(fullFilename).fileName()
30
31
32
33def toBool(value):
34    """Convert string value to bool.
35
36    Legacy function from PyQt MDI Image Viewer by tpgit.
37
38    Args:
39        value (any)
40    
41    Returns:
42        value (bool)
43    """
44    if value in ["true", "1", "True"]:
45        return True
46    elif value in ["false", "0", "False"]:
47        return False
48    else:
49        return bool(value)
def strippedName(fullFilename):
19def strippedName(fullFilename):
20    """Get filename from a filepath.
21
22    Legacy function from PyQt MDI Image Viewer by tpgit.
23
24    Args:
25        fullFilename (str): The filepath (the "full" filename).
26    
27    Returns:
28        value (str): The filename as stripped from the filepath.
29    """
30    return QtCore.QFileInfo(fullFilename).fileName()

Get filename from a filepath.

Legacy function from PyQt MDI Image Viewer by tpgit.

Arguments:
  • fullFilename (str): The filepath (the "full" filename).
Returns:
  • value (str): The filename as stripped from the filepath.
def toBool(value):
34def toBool(value):
35    """Convert string value to bool.
36
37    Legacy function from PyQt MDI Image Viewer by tpgit.
38
39    Args:
40        value (any)
41    
42    Returns:
43        value (bool)
44    """
45    if value in ["true", "1", "True"]:
46        return True
47    elif value in ["false", "0", "False"]:
48        return False
49    else:
50        return bool(value)

Convert string value to bool.

Legacy function from PyQt MDI Image Viewer by tpgit.

Arguments:
  • value (any)
Returns:
  • value (bool)