Skip to content
Snippets Groups Projects
Commit 35e5f302 authored by JOSSOUD Olivier's avatar JOSSOUD Olivier
Browse files

ConductCalib. Highlight selected row of "set" table.

parent 887e3dbf
No related branches found
No related tags found
No related merge requests found
......@@ -116,6 +116,8 @@ class ConductCalibUim:
steps_item.setText(str(calib_run.instant_config_df["step"].max()))
self.main_ui.conduct_tablewidget_set.setItem(row_id, self.STEPS_COL, steps_item)
utils.highlight_row(self.main_ui.conduct_tablewidget_set, row_id)
def change_selected_run(self, row: int, column: int):
# Get run identifier (date and time concatenated)
identifier = self.main_ui.conduct_tablewidget_set.item(row, self.DATE_COL).text() \
......@@ -126,6 +128,8 @@ class ConductCalibUim:
self.current_calib_run = calib_run
utils.highlight_row(self.main_ui.conduct_tablewidget_set, row)
self.__update_run_plot__(calib_run, self.current_channel)
self.__update_run_table__(calib_run, self.current_channel)
......
......@@ -2,6 +2,8 @@ import pyqtgraph as pg
import datetime
import pandas as pd
import numpy as np
from PyQt5.QtWidgets import QTableWidget
from PyQt5.QtGui import QColor
def pd_time_to_epoch_ms(series: pd.Series) -> list:
......@@ -13,8 +15,10 @@ def pd_time_to_epoch_ms(series: pd.Series) -> list:
def datetime64_to_epoch_ms(datetimes_list: np.ndarray) -> list:
return [float(instant) / 1e9 for instant in datetimes_list]
####################################################################
# Graphics
class TimeAxisItem(pg.AxisItem):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
......@@ -24,3 +28,31 @@ class TimeAxisItem(pg.AxisItem):
def tickStrings(self, values, scale, spacing):
return [datetime.datetime.fromtimestamp(value).strftime("%H:%M:%S") for value in values]
def highlight_row(table: QTableWidget, highlighted_row_id: int,
highlighted_row_color: QColor = QColor(173, 216, 230),
other_rows_color: QColor = QColor(255, 255, 255)) -> None:
"""Highlight a table's row by changing its background color.
Parameters
----------
table: PyQt5.QtWidgets.QTableWidget
Table whose row should be highlighted.
highlighted_row_id: int
Index (first row is 0) of the row which should be highlighted.
highlighted_row_color: PyQt5.QtGui.QColor
Background color of the highlighted row. Default is light blue.
other_rows_color: PyQt5.QtGui.QColor
Background color of the other rows of the table. Default is white.
Returns
-------
Nothing, modify the input ``table``
"""
for row_id in range(table.rowCount()):
if row_id == highlighted_row_id:
row_color = highlighted_row_color
else:
row_color = other_rows_color
for column_id in range(table.columnCount()):
table.item(row_id, column_id).setBackground(row_color)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment