def show_record(record): """Create a :class:`QtWidgets.QDialog` to display the information about a record. Parameters ---------- record : :class:`~msl.equipment.record_types.EquipmentRecord` or :class:`~msl.equipment.record_types.ConnectionRecord` An Equipment Record or a Connection Record. """ dialog = QtWidgets.QDialog() dialog.setWindowFlags(QtCore.Qt.WindowCloseButtonHint) dialog.setWindowTitle(record.__class__.__name__.replace('R', ' R')) widget = QtWidgets.QTextEdit() widget.setReadOnly(True) widget.setLineWrapMode(QtWidgets.QTextEdit.NoWrap) widget.setText(record.to_yaml()) hbox = QtWidgets.QHBoxLayout() hbox.addWidget(widget) dialog.setLayout(hbox) size = widget.document().size() sb = widget.horizontalScrollBar().size().height() dialog.resize(int((size.width() + sb) * 1.1), int((size.height() + sb) * 1.1)) # add 10% dialog.exec_()
def show_hardware_info(connection): """Displays the hardware information about a Thorlabs_ :class:`~msl.equipment.resources.thorlabs.kinesis.motion_control.MotionControl` device in a :class:`QtWidgets.QDialog`. Parameters ---------- connection : :class:`~msl.equipment.resources.thorlabs.kinesis.motion_control.MotionControl` A Thorlabs Motion Control subclass. """ info = connection.get_hardware_info() dialog = QtWidgets.QDialog() dialog.setWindowFlags(QtCore.Qt.WindowCloseButtonHint) dialog.setWindowTitle(connection.__class__.__name__) widget = QtWidgets.QTextEdit() widget.setReadOnly(True) widget.setLineWrapMode(QtWidgets.QTextEdit.NoWrap) text = 'Serial Number: {}\n'.format(info.serialNumber) text += 'Model Number: {}\n'.format(info.modelNumber.decode('utf-8')) text += 'Type: {}\n'.format(info.type) text += 'Number of Channels: {}\n'.format(info.numChannels) text += 'Notes: {}\n'.format(info.notes.decode('utf-8')) text += 'Firmware Version: {}\n'.format( connection.to_version(info.firmwareVersion)) text += 'Hardware Version: {}\n'.format( connection.to_version(info.hardwareVersion)) text += 'Modification State: {}'.format(info.modificationState) widget.setText(text) hbox = QtWidgets.QHBoxLayout() hbox.addWidget(widget) dialog.setLayout(hbox) size = widget.document().size() pad = widget.horizontalScrollBar().size().height() * 1.1 dialog.resize(int(size.width() + pad), int(size.height() + pad)) dialog.exec_()