DvG_PyQt_FileLogger
Provides a PyQt interface to handle logging data to a file particularly well suited for multithreaded programs.
Supports PyQt5, PyQt6, PySide2 and PySide6.
Installation:
pip install dvg-pyqt-filelogger
Example usage
The following are snippets of code, not a full program.
from qtpy import QtWidgets as QtWid
from dvg_pyqt_filelogger import FileLogger
# Main/GUI thread
# ---------------
class MainWindow(QtWid.QWidget):
def __init__(
self,
log: FileLogger,
parent=None,
**kwargs
):
super().__init__(parent, **kwargs)
# Create a record button
self.record_button = QtWid.QPushButton("Click to start recording to file")
self.record_button.setCheckable(True)
self.record_button.clicked.connect(lambda state: log.record(state))
class YourDataGeneratingDevice:
reading_1 = 0.0
device = YourDataGeneratingDevice()
def write_header_to_log():
log.write("elapsed [s]\treading_1\n")
def write_data_to_log():
log.write(f"{log.elapsed():.3f}\t{device.reading_1:.4f}\n")
log = FileLogger(
write_header_function=write_header_to_log,
write_data_function=write_data_to_log
)
log.signal_recording_started.connect(
lambda filepath: window.record_button.setText(
f"Recording to file: {filepath}"
)
)
log.signal_recording_stopped.connect(
lambda: window.record_button.setText(
"Click to start recording to file"
)
)
window = MainWindow(log)
# Data acquisition and/or logging thread
# --------------------------------------
# New data got acquired
device.reading_1 = 20.3
# Must be called whenever new data has become available
log.update()
API
Class FileLogger
FileLogger(
write_header_function: Callable | None = None,
write_data_function: Callable | None = None,
encoding: str = "utf-8",
)
Changelog
1.4.0 (2024-06-24)
Using qtpy library instead of my own Qt5/6 mechanism
Support for Numpy 2.0
Extended API and docstrings
Added argument encoding, defaulting to “utf-8”
Added type hints
Added method get_filepath()
1.3.0 (2023-02-27)
Raise ImportError instead of general Exception
1.2.0 (2022-09-13)
Added support for PyQt5, PyQt6, PySide2 and PySide6
1.1.0 (2021-05-13)
Added support for numpy.savetxt()
1.0.0 (2020-08-11)
First release on PyPI
Metadata
Release files for dvg-pyqt-filelogger 1.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dvg_pyqt_filelogger-1.4.0.tar.gz | 10.3 kB | Without provenance | Details for dvg_pyqt_filelogger-1.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dvg_pyqt_filelogger-1.4.0-py3-none-any.whl | Python 3 | none | any | Details for dvg_pyqt_filelogger-1.4.0-py3-none-any.whl |
Total release size: 19.9 kB
Release files / dvg_pyqt_filelogger-1.4.0.tar.gz
| Download URL | dvg_pyqt_filelogger-1.4.0.tar.gz |
|---|---|
| Size | 10.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5245742f95ce9a571584fe2d5f046993e9553ccb9067de2d6752d3579d6f3f3d
|
|
BLAKE2b-256 checksum How to use checksums |
0a625c892c03d0606040b46628b12b4b5ea1f77443f1ef0640f8e5dc09a961ab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.4
|
Release files / dvg_pyqt_filelogger-1.4.0-py3-none-any.whl
| Download URL | dvg_pyqt_filelogger-1.4.0-py3-none-any.whl |
|---|---|
| Size | 9.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5fac1d8cc9b79668c9a5dddb8e50f26dfffb270d38aef8138652c18d4bc50326
|
|
BLAKE2b-256 checksum How to use checksums |
25cee47b5801ac516a5b4743f22f01b0831b847627cf0fa200c1f6ba87da7322
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.4
|
Security for dvg-pyqt-filelogger 1.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.