Module: utils

Module for general utilities and standalone methods that don’t globally import from anywhere in flika

Submodule: utils.misc

flika.utils.misc.nonpartial(func, *args, **kwargs)

Like functools.partial, this returns a function which, when called, calls func(*args, **kwargs).

Unlike functools.partial, extra arguments passed to the returned function are not passed to the input function.

flika.utils.misc.random_color()

Generate an QColor that is bright enough to see on a black and white background

Returns:randomly generated color object
Return type:QtGui.QColor
flika.utils.misc.load_ui(path, parent=None, directory=None)

Load a .ui file

Parameters:
  • path (str) – Name of ui file to load
  • parent (QtCore.QObject) – Object to use as the parent of this widget
Returns:

The widget created from the specified ui file

Return type:

QtWidgets.QWidget

flika.utils.misc.save_file_gui(prompt='Save file', directory=None, filetypes='')

File dialog for saving a new file, isolated to handle tuple/string return value

Parameters:
  • prompt (str) – string to display at the top of the window
  • directory (str) – initial directory to save the file to
  • filetypes (str) – argument for filtering file types separated by ;; (.png) or (Images *.png);;(Other *.)
Returns:

the file path selected, or empty string if canceled

Return type:

str

flika.utils.misc.open_file_gui(prompt='Open File', directory=None, filetypes='')

File dialog for opening an existing file, isolated to handle tuple/string return value

Parameters:
  • prompt (str) – string to display at the top of the window
  • directory (str) – initial directory to open
  • filetypes (str) – argument for filtering file types separated by ;; (.png) or (Images *.png);;(Other *.)
Returns:

the file (path+file+extension) selected, or None

Return type:

str

Submodule: utils.app

flika.utils.app.get_qapp(icon_path=None)

Get the QApplication instance currently in use. If no QApplication exists, one is created and the standard windoe icon is set to icon_path

Parameters:icon_path (str) – location of icon to use as default window icon
Returns:the current application process
Return type:QtGui.QApplication