Files
templates/python/set_devices/qt_ports/tektronix_controls.py

25 lines
802 B
Python

"""Tektronix-style record-length selector, including instrument readback."""
try:
from PySide6.QtWidgets import QComboBox
except ImportError:
from PySide2.QtWidgets import QComboBox
from set_devices.tektronix_presets import RECORD_LENGTHS
class RecordLengthBox(QComboBox):
def __init__(self, parent=None):
super().__init__(parent)
for value in RECORD_LENGTHS:
self.addItem(f"{value:,}".replace(",", " ") + " точек", value)
def value(self):
return int(self.currentData())
def setValue(self, value):
value = int(value)
index = self.findData(value)
if index < 0:
self.addItem(f"{value:,}".replace(",", " ") + " точек", value)
index = self.count() - 1
self.setCurrentIndex(index)