wonambi.widgets.utils module
Various functions used for the GUI.
- class wonambi.widgets.utils.FormBool(checkbox_label)[source]
Bases:
QCheckBox
Subclass QCheckBox to have a more consistent API across widgets.
- Parameters:
checkbox_label (str) – label next to checkbox
- connect(funct)[source]
Call funct when user ticks the box.
- Parameters:
funct (function) – function that broadcasts a change.
- class wonambi.widgets.utils.FormDir[source]
Bases:
QPushButton
Subclass QPushButton for str to have a more consistent API across widgets.
Notes
It calls to open the directory three times, but I don’t understand why
- connect(funct)[source]
Call funct when the text was changed.
- Parameters:
funct (function) – function that broadcasts a change.
Notes
There is something wrong here. When you run this function, it calls for opening a directory three or four times. This is obviously wrong but I don’t understand why this happens three times. Traceback did not help.
- class wonambi.widgets.utils.FormFloat(default=None, maxw=None, significant_digits=3)[source]
Bases:
QLineEdit
Subclass QLineEdit for float to have a more consistent API across widgets.
- Parameters:
significant_digits (int) – number of significant digits
- connect(funct)[source]
Call funct when the text was changed.
- Parameters:
funct (function) – function that broadcasts a change.
- class wonambi.widgets.utils.FormInt(default=None)[source]
Bases:
QLineEdit
Subclass QLineEdit for int to have a more consistent API across widgets.
- connect(funct)[source]
Call funct when the text was changed.
- Parameters:
funct (function) – function that broadcasts a change.
- class wonambi.widgets.utils.FormList[source]
Bases:
QLineEdit
Subclass QLineEdit for lists to have a more consistent API across widgets.
- connect(funct)[source]
Call funct when the text was changed.
- Parameters:
funct (function) – function that broadcasts a change.
- class wonambi.widgets.utils.FormMenu(input_list)[source]
Bases:
QComboBox
Subclass QComboBox for dropdown menus to have a more consistent API across widgets.
- Parameters:
input_list (list of str) – items to include in the dropdown menu / combobox
- connect(funct)[source]
Call funct when the selection was changed.
- Parameters:
funct (function) – function that broadcasts a change.
- class wonambi.widgets.utils.FormRadio(checkbox_label)[source]
Bases:
QRadioButton
Subclass QRadioButton to have a more consistent API across widgets.
- Parameters:
checkbox_label (str) – label next to checkbox
- connect(funct)[source]
Call funct when user ticks the box.
- Parameters:
funct (function) – function that broadcasts a change.
- class wonambi.widgets.utils.FormSpin(default=None, min_val=None, max_val=None, step=None)[source]
Bases:
QSpinBox
Subclass QSpinBox for int to have a more consistent API across widgets.
- connect(funct)[source]
Call funct when the text was changed.
- Parameters:
funct (function) – function that broadcasts a change.
- class wonambi.widgets.utils.FormStr[source]
Bases:
QLineEdit
Subclass QLineEdit for str to have a more consistent API across widgets.
- connect(funct)[source]
Call funct when the text was changed.
- Parameters:
funct (function) – function that broadcasts a change.
- class wonambi.widgets.utils.Path(x, y)[source]
Bases:
QPainterPath
Paint a line in the simplest possible way.
- Parameters:
x (ndarray or list) – x-coordinates
y (ndarray or list) – y-coordinates
- class wonambi.widgets.utils.RectMarker(x, y, width, height, zvalue, color='blue')[source]
Bases:
QGraphicsRectItem
Class to draw a rectangular, coloured item.
- Parameters:
x (float) – x position in scene
y (gloat) – y position in scene
width (float) – length in seconds
height (float) – height in scene units
color (str or QColor, optional) – color of the rectangle
- class wonambi.widgets.utils.TextItem_with_BG(bg_color='black')[source]
Bases:
QGraphicsSimpleTextItem
Class to draw text with dark background (easier to read).
- Parameters:
bg_color (str or QColor, optional) – color to use as background
- wonambi.widgets.utils.choose_file_or_dir()[source]
Create a simple message box to see if the user wants to open dir or file
- Returns:
str – ‘dir’ or ‘file’ or ‘abort’
- wonambi.widgets.utils.convert_name_to_color(s)[source]
Convert any string to an RGB color.
- Parameters:
s (str) – string to convert
selection (bool, optional) – if an event is being selected, it’s lighter
- Returns:
instance of QColor – one of the possible color
Notes
It takes any string and converts it to RGB color. The same string always returns the same color. The numbers are a bit arbitrary but not completely. h is the baseline color (keep it high to have brighter colors). Make sure that the max module + h is less than 256 (RGB limit).
The number you multiply ord for is necessary to differentiate the letters (otherwise ‘r’ and ‘s’ are too close to each other).
- wonambi.widgets.utils.export_graphics_to_svg(widget, filename)[source]
Export graphics to svg
- Parameters:
widget (instance of QGraphicsView) – traces or overview
filename (str) – path to save svg
- wonambi.widgets.utils.freq_from_str(freq_str)[source]
Obtain frequency ranges from input string, either as list or dynamic notation.
- Parameters:
freq_str (str) – String with frequency ranges, either as a list: e.g. [[1-3], [3-5], [5-8]]; or with a dynamic definition: (start, stop, width, step).
- Returns:
list of tuple of float or None – Every tuple of float represents a frequency band. If input is invalid, returns None.
- wonambi.widgets.utils.keep_recent_datasets(max_dataset_history, info=None)[source]
Keep track of the most recent recordings.
- Parameters:
max_dataset_history (int) – maximum number of datasets to remember
info (str, optional TODO) – path to file
- Returns:
list of str – paths to most recent datasets (only if you don’t specify new_dataset)
- wonambi.widgets.utils.select_session(sessions)[source]
Select one session out of a list of sessions.
- Parameters:
sessions (list) – list of integers
- Returns:
None or int – index of the session being chosen
- wonambi.widgets.utils.stdicon()
standardIcon(self, QStyle.StandardPixmap, option: QStyleOption = None, widget: QWidget = None) -> QIcon