def create_widgets(self, parent, refresh_callback): self._refresh_callback = refresh_callback self.prefix_label = QLabel() font = self.prefix_label.font() font.setPointSize(font.pointSize() + self._size_offset) self.prefix_label.setFont(font) self.button = QPushButton() self.button.setIcon(get_icon('settings.png')) self.button.setToolTip( _("Edit '%s' fit parameter properties") % self.name) QObject.connect(self.button, SIGNAL('clicked()'), lambda: self.edit_param(parent)) self.lineedit = QLineEdit() QObject.connect(self.lineedit, SIGNAL('editingFinished()'), self.line_editing_finished) self.unit_label = QLabel(self.unit) self.slider = QSlider() self.slider.setOrientation(Qt.Horizontal) self.slider.setRange(0, self.steps - 1) QObject.connect(self.slider, SIGNAL("valueChanged(int)"), self.slider_value_changed) self.update(refresh=False) self.add_widgets([ self.prefix_label, self.lineedit, self.unit_label, self.slider, self.button ])
def __init__(self, parent, appdata): super(SessionInfos, self).__init__(parent) self.appdata = appdata self.setWindowTitle( 'Information for the session' ) self.setFixedSize(250, 300) self.buttonBox = QDialogButtonBox( self ) self.buttonBox.setOrientation( Qt.Horizontal ) self.buttonBox.setStandardButtons( QDialogButtonBox.Cancel|QDialogButtonBox.Ok ) labelcombo = QLabel( 'Breathing Zone:' ) self.breathzone = QComboBox() self.breathzone.addItem( '', '' ) self.breathzone.addItem( 'Abdominal', 1 ) self.breathzone.addItem( 'Thoracic', 2 ) self.breathzone.move(10, 10) labelnote = QLabel( 'Note:' ) self.note = QTextEdit() layout = QVBoxLayout() layout.addWidget( self.create_SessionType_Group() ) layout.addWidget( labelcombo ) layout.addWidget( self.breathzone ) layout.addWidget( labelnote ) layout.addWidget( self.note ) layout.addWidget( self.buttonBox ) self.setLayout( layout ) self.buttonBox.accepted.connect( self.accept ) self.buttonBox.rejected.connect( self.reject )
def __init__(self, parent): super(MakeNicerWidget, self).__init__(parent) self.data = np.array([]) # array which holds data # Time domain plot self.tdWidget = DockablePlotWidget(self, CurveWidget) self.tdWidget.calcFun.addFun('fs', lambda x: x, lambda x: x) self.tdWidget.calcFun.addFun('µm', lambda x: x * fsDelay * 1e3, lambda x: x / fsDelay * 1e-3) self.tdWidget.calcFun.addFun('mm', lambda x: x * fsDelay, lambda x: x / fsDelay) tdPlot = self.tdWidget.get_plot() self.tdSignal = SignalFT(self, plot=tdPlot) self.tdFit = SignalFT(self, plot=tdPlot, col='r') # Frequency domain plot self.fdWidget = DockablePlotWidget(self, CurveWidget) self.fdWidget.calcFun.addFun('PHz', lambda x: x, lambda x: x) self.fdWidget.calcFun.addFun('THz', lambda x: x * 1e3, lambda x: x * 1e-3) self.fdWidget.calcFun.addFun('µm', lambda x: c0 / x * 1e-9, lambda x: c0 / x * 1e-9) self.fdWidget.calcFun.addFun('eV', lambda x: x, lambda x: x) fdplot = self.fdWidget.get_plot() self.fdSignal = SignalFT(self, plot=fdplot) self.fdFit = SignalFT(self, plot=fdplot, col='r') self.smoothNum = QSpinBox() # gives number of smoothin points self.smoothNum.setMinimum(1) self.smoothNum.setSingleStep(2) # Put things together in layouts buttonLayout = QGridLayout() plotLayout = QVBoxLayout() layout = QHBoxLayout() plotLayout.addWidget(self.tdWidget) plotLayout.addWidget(self.fdWidget) buttonLayout.addWidget(QLabel('Fitting function'), 0, 0) buttonLayout.addWidget( QLineEdit("lambda x,A,f,phi: np.sin(2*np.pi*f*x+phi)"), 1, 0, 1, 2) buttonLayout.addWidget(QLabel('Smooth'), 2, 0) buttonLayout.addWidget(self.smoothNum, 2, 1) buttonLayout.setRowStretch(3, 20) layout.addLayout(buttonLayout) layout.addLayout(plotLayout) self.setLayout(layout) # connect signals self.updateTdPlot.connect(self.tdSignal.updatePlot) self.updateTdFitPlot.connect(self.tdFit.updatePlot) self.updateFdPlot.connect(lambda data: self.fdSignal.updatePlot( self.fdSignal.computeFFT(data))) self.updateFdFitPlot.connect( lambda data: self.fdFit.updatePlot(self.fdFit.computeFFT(data))) self.smoothNum.valueChanged.connect(self.smoothData) self.setData()
def add_buttons_to_layout(self, layout): """Add tool buttons to layout""" # Image orientation angle_label = QLabel(_("Angle (°):")) layout.addWidget(angle_label) self.angle_combo = QComboBox(self) self.angle_combo.addItems(self.ROTATION_ANGLES) self.angle_combo.setCurrentIndex(1) self.angle_combo.currentIndexChanged.connect( lambda index: self.apply_transformation()) layout.addWidget(self.angle_combo) layout.addSpacing(10) # Image flipping flip_label = QLabel(_("Flip:")) layout.addWidget(flip_label) hflip = create_toolbutton( self, text="", icon=get_icon("hflip.png"), toggled=lambda state: self.apply_transformation(), autoraise=False) self.hflip_btn = hflip layout.addWidget(hflip) vflip = create_toolbutton( self, text="", icon=get_icon("vflip.png"), toggled=lambda state: self.apply_transformation(), autoraise=False) self.vflip_btn = vflip layout.addWidget(vflip) layout.addSpacing(15) self.add_reset_button(layout)
def __init__(self, parent): QSplitter.__init__(self, parent) self.parent = parent self.setContentsMargins(10, 10, 10, 10) self.setOrientation(Qt.Vertical) # # Spectrometers in tabs self.tabs = SpectrometerTabs(self, ['AFFTS']) # Toolbar self.toolbar = ToolBar(parent.Icons) self.toolbar.setOrientation(Qt.Vertical) # Control panel (housekeeping) self.controlpanel = ControlPanel(self) # Status bar self.statusbar = QStatusBar() self.ActionIcon = QLabel(u"") self.ActionInfo = QLabel(u"") self.statusbar.addPermanentWidget(self.ActionIcon) self.statusbar.addPermanentWidget(self.ActionInfo, 1) self.addWidget(self.tabs) Hsplit = QSplitter() Hsplit.setOrientation(Qt.Horizontal) Hsplit.addWidget(self.toolbar) Hsplit.addWidget(self.controlpanel) self.addWidget(Hsplit) self.addWidget(self.statusbar) self.setSizes([2000, 1, 1, 1])
def __init__(self, parent=None): QWidget.__init__(self, parent) self.widget_layout = QVBoxLayout() title_layout = QHBoxLayout() title_layout.addStretch() style = "<span style=\'color: #444444\'><b>%s</b></span>" title = QLabel(style % "Operations") title_layout.addWidget(title) title_layout.addStretch() self.widget_layout.addLayout(title_layout) # Create ListWidget and add 10 items to move around. self.list_widget = QListWidget() # self.list_widget.setDragDropMode(QAbstractItemView.InternalMove) self.list_widget.setSelectionMode(QAbstractItemView.ExtendedSelection) self.list_widget.setSortingEnabled(False) self.list_widget.currentItemChanged.connect(self._populate_settings_update) self.widget_layout.addWidget(self.list_widget) otitle_layout = QHBoxLayout() otitle_layout.addStretch() otitle = QLabel(style % "Operation settings") otitle_layout.addWidget(otitle) otitle_layout.addStretch() self.widget_layout.addLayout(otitle_layout) self.operations_combo = QComboBox() self.operations_combo.currentIndexChanged.connect(self._populate_settings_add) self.widget_layout.addWidget(self.operations_combo) self.operation_settings = GenericOperationWidget() self.widget_layout.addWidget(self.operation_settings) self.toolbar = QToolBar() self.toolbar.addAction(get_icon('apply.png'), "Apply/Replace", self._change_operation) self.toolbar.addAction(get_icon('editors/edit_add.png'), "Add after", self._add_operation) self.toolbar.addAction(get_icon('trash.png'), "Remove", self._remove_operation) self.widget_layout.addWidget(self.toolbar) self.setLayout(self.widget_layout)
def __init__(self, item, parent_layout): AbstractDataSetWidget.__init__(self, item, parent_layout) self.group = QLabel() wordwrap = item.get_prop_value("display", "wordwrap", False) self.group.setWordWrap(wordwrap) self.group.setToolTip(item.get_help()) self.group.setStyleSheet( LABEL_CSS ) self.group.setTextInteractionFlags(Qt.TextSelectableByMouse)
def get_image_label(name, default="not_found.png"): """ Construct a QLabel from the file with specified name name, default: filenames with extensions """ label = QLabel() pixmap = QPixmap(get_image_file_path(name, default)) label.setPixmap(pixmap) return label
def __init__(self, getIcon, *args, **kwargs): QStatusBar.__init__(self, *args, **kwargs) self.ActionIcon = QLabel(u"") self.ActionInfo = QLabel(u"") self.ActionInfo.setFixedWidth(200) self.StreamInfo = QLabel(u"") self.addPermanentWidget(self.ActionIcon) self.addPermanentWidget(self.ActionInfo) openIcon = QLabel(u"") openIcon.setPixmap(getIcon("arrow").pixmap(QSize(16, 16))) self.addPermanentWidget(openIcon) self.addPermanentWidget(self.StreamInfo, 1) self.getIcon = getIcon self._stdout = sys.stdout self._txtStream = io.StringIO() sys.stdout = self._txtStream
def __init__(self, parent=None, tdms_file=None, group_label="Data group", channel_labels=["X channel", "Y channel", "Z channel", "Z2 channel", ]): """ Params ====== twin_z : bool Allow to select two Z (data) channels group_label : str: Label text for group combo box channel_labels : list of str Label texts for channel combo boxes """ QWidget.__init__(self, parent) self.widget_layout = QVBoxLayout() self.group_widgets = [] self.channel_widgets = [] for i, label_text in enumerate([group_label] + channel_labels): label = QLabel(label_text) channel_widget = QComboBox() channel_widget.addItem(label_text) channel_widget.setMinimumWidth(250) channel_widget.setDisabled(True) group_widget = QComboBox() group_widget.addItem(label_text) group_widget.setMinimumWidth(250) group_widget.setDisabled(True) layout = QHBoxLayout() layout.addWidget(label) layout.addWidget(group_widget) if i != 0: layout.addWidget(channel_widget) self.widget_layout.addLayout(layout) if i == 0: self.group_combo = group_widget self.group_combo.currentIndexChanged.connect(self.change_sub_channels) else: self.group_widgets.append(group_widget) self.channel_widgets.append(channel_widget) group_widget.currentIndexChanged.connect(self._populate_channels) self.setLayout(self.widget_layout) self.tdms_file = tdms_file
def place_label(self, layout, row, column): """ Place item label on layout at specified position (row, column) """ label_text = self.item.get_prop_value("display", "label") unit = self.item.get_prop_value("display", "unit", '') if unit and not self.READ_ONLY: label_text += (' (%s)' % unit) self.label = QLabel(label_text) self.label.setToolTip(self.item.get_help()) layout.addWidget(self.label, row, column)
def __init__(self, parent): QWidget.__init__(self, parent) font = QFont(get_family(MONOSPACE), 10, QFont.Normal) info_icon = QLabel() icon = get_std_icon('MessageBoxInformation').pixmap(24, 24) info_icon.setPixmap(icon) info_icon.setFixedWidth(32) info_icon.setAlignment(Qt.AlignTop) self.desc_label = QLabel() self.desc_label.setWordWrap(True) self.desc_label.setAlignment(Qt.AlignTop) self.desc_label.setFont(font) group_desc = QGroupBox(_("Description"), self) layout = QHBoxLayout() layout.addWidget(info_icon) layout.addWidget(self.desc_label) group_desc.setLayout(layout) self.editor = CodeEditor(self) self.editor.setup_editor(linenumbers=True, font=font) self.editor.setReadOnly(True) group_code = QGroupBox(_("Source code"), self) layout = QVBoxLayout() layout.addWidget(self.editor) group_code.setLayout(layout) self.run_button = QPushButton(get_icon("apply.png"), _("Run this script"), self) self.quit_button = QPushButton(get_icon("exit.png"), _("Quit"), self) hlayout = QHBoxLayout() hlayout.addWidget(self.run_button) hlayout.addStretch() hlayout.addWidget(self.quit_button) vlayout = QVBoxLayout() vlayout.addWidget(group_desc) vlayout.addWidget(group_code) vlayout.addLayout(hlayout) self.setLayout(vlayout)
def __init__(self, parent): super(FileUi, self).__init__(Qt.Vertical, parent) layoutWidget = QWidget() layout = QVBoxLayout() layoutWidget.setLayout(layout) self.comment = QPlainTextEdit() self.fileName = None self.saveTxtCheck = QCheckBox('Save Txt') self.saveHdfCheck = QCheckBox('Save HDF5') self.saveTxtBtn = QPushButton('Save Txt') self.saveHdfBtn = QPushButton('Save HDF5') ############# # stream group streamGroup = QGroupBox('Stream data to file:') streamGroup.setFlat(True) streamGroupLayout = QHBoxLayout() streamGroupLayout.addWidget(self.saveTxtCheck) streamGroupLayout.addWidget(self.saveHdfCheck) streamGroup.setLayout(streamGroupLayout) ############## # save static file saveGroup = QGroupBox('Save now to file:') saveGroup.setFlat(True) saveGroupLayout = QHBoxLayout() saveGroupLayout.addWidget(self.saveTxtBtn) saveGroupLayout.addWidget(self.saveHdfBtn) saveGroup.setLayout(saveGroupLayout) ############## # put layout together layout.addWidget(QLabel('Comment:')) layout.addWidget(self.comment) layout.addWidget(streamGroup) layout.addWidget(saveGroup) self.addWidget(layoutWidget) ############## # connnect stuff for functionality self.saveTxtCheck.stateChanged.connect(self.__makeFileName) self.saveHdfCheck.stateChanged.connect(self.__makeFileName) ############## # thread for streaming data to file #self.updateCurrPos.connect(self.__updateCurrPos) self.stream_thread = QThread() # create the QThread self.stream_thread.start() self.stream_worker = GenericWorker(self.__streamFile) self.stream_worker.moveToThread(self.stream_thread)
def __init__(self, label, klass, wordwrap=False, **kwargs): QGroupBox.__init__(self, label) self.klass = klass self.dataset = klass(**kwargs) self.layout = QVBoxLayout() if self.dataset.get_comment(): label = QLabel(self.dataset.get_comment()) label.setWordWrap(wordwrap) self.layout.addWidget(label) self.grid_layout = QGridLayout() self.layout.addLayout(self.grid_layout) self.setLayout(self.layout) self.edit = self.get_edit_layout()
def __init__(self, parent=None): QWidget.__init__(self, parent) self.layout = QHBoxLayout() self.widgets = [] for i, label_text in enumerate(["start", "stop", "step"]): label = QLabel(label_text) argument_widget = QLineEdit() self.layout.addWidget(label) self.layout.addWidget(argument_widget) self.widgets.append(argument_widget) self.setLayout(self.layout) self.slice = slice(None)
def get_image_layout(imagename, text="", tooltip="", alignment=Qt.AlignLeft): """ Construct a QHBoxLayout including image from the file with specified name, left-aligned text [with specified tooltip] Return (layout, label) """ layout = QHBoxLayout() if alignment in (Qt.AlignCenter, Qt.AlignRight): layout.addStretch() layout.addWidget(get_image_label(imagename)) label = QLabel(text) label.setToolTip(tooltip) layout.addWidget(label) if alignment in (Qt.AlignCenter, Qt.AlignLeft): layout.addStretch() return (layout, label)
def __init__(self, instance, icon='', parent=None, apply=None, wordwrap=True, size=None): QDialog.__init__(self, parent) self.wordwrap = wordwrap self.apply_func = apply self.layout = QVBoxLayout() if instance.get_comment(): label = QLabel(instance.get_comment()) label.setWordWrap(wordwrap) self.layout.addWidget(label) self.instance = instance self.edit_layout = [] self.setup_instance(instance) if apply is not None: apply_button = QDialogButtonBox.Apply else: apply_button = QDialogButtonBox.NoButton bbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel | apply_button) self.bbox = bbox bbox.accepted.connect(self.accept) bbox.rejected.connect(self.reject) bbox.clicked.connect(self.button_clicked) self.layout.addWidget(bbox) self.setLayout(self.layout) if parent is None: if not isinstance(icon, QIcon): icon = get_icon(icon, default="guidata.svg") self.setWindowIcon(icon) self.setModal(True) self.setWindowTitle(instance.get_title()) if size is not None: if isinstance(size, QSize): self.resize(size) else: self.resize(*size)
def __init__(self, parent): super(controlWidget, self).__init__() self.widgetTimer = QTimer() self.widgetTimer.start(100) self.widgetTimer.timeout.connect(self.createNewDspWidgets) self.value =0 self.flag = True self.mainApp = parent self.inactivityTimeout = True self.setWindowTitle('Live Telemetry Visualizer') self.qbtn = QPushButton('Quit', self) self.qbtn.clicked.connect(self.mainApp.quit) self.qbtn.resize(self.qbtn.sizeHint()) self.qbtn.hide() qbtn1 = QPushButton('Check Performance status') qbtn1.clicked.connect(self.ButtonPressed) qbtn1.resize(qbtn1.sizeHint()) self.performance_status = QLabel("If Performance Curve at Monitor Mic is On turn it Off") self.performance_status.hide() icheck = QCheckBox('Inactivity Timeout') icheck.stateChanged.connect(self.toggleInactivity) icheck.setChecked(self.inactivityTimeout) layout = QVBoxLayout() self.setLayout(layout) layout.addWidget(self.qbtn) layout.addWidget(self.performance_status) layout.addWidget(qbtn1) layout.addWidget(icheck) layout.addWidget(QWidget()) self.resize(180, 100) self.show()
def __init__(self, parent): QWidget.__init__(self, parent) layout = QHBoxLayout() row_nb = 14 cindex = 0 for child in dir(QStyle): if child.startswith('SP_'): if cindex == 0: col_layout = QVBoxLayout() icon_layout = QHBoxLayout() icon = get_std_icon(child) label = QLabel() label.setPixmap(icon.pixmap(32, 32)) icon_layout.addWidget(label) icon_layout.addWidget(QLineEdit(child.replace('SP_', ''))) col_layout.addLayout(icon_layout) cindex = (cindex + 1) % row_nb if cindex == 0: layout.addLayout(col_layout) self.setLayout(layout) self.setWindowTitle('Standard Platform Icons') self.setWindowIcon(get_std_icon('TitleBarMenuButton'))
def setup_instance(self, instance): """Override DataSetEditDialog method""" from guidata.dataset.datatypes import DataSetGroup assert isinstance(instance, DataSetGroup) tabs = QTabWidget() # tabs.setUsesScrollButtons(False) self.layout.addWidget(tabs) for dataset in instance.datasets: layout = QVBoxLayout() layout.setAlignment(Qt.AlignTop) if dataset.get_comment(): label = QLabel(dataset.get_comment()) label.setWordWrap(self.wordwrap) layout.addWidget(label) grid = QGridLayout() self.edit_layout.append( self.layout_factory(dataset, grid) ) layout.addLayout(grid) page = QWidget() page.setLayout(layout) if dataset.get_icon(): tabs.addTab( page, get_icon(dataset.get_icon()), dataset.get_title() ) else: tabs.addTab( page, dataset.get_title() )
def __init__(self, parent): QWidget.__init__(self, parent) font = QFont(get_family(MONOSPACE), 10, QFont.Normal) info_icon = QLabel() icon = get_std_icon('MessageBoxInformation').pixmap(24, 24) info_icon.setPixmap(icon) info_icon.setFixedWidth(32) info_icon.setAlignment(Qt.AlignTop) self.service_status_label = QLabel() self.service_status_label.setWordWrap(True) self.service_status_label.setAlignment(Qt.AlignTop) self.service_status_label.setFont(font) self.desc_label = QLabel() self.desc_label.setWordWrap(True) self.desc_label.setAlignment(Qt.AlignTop) self.desc_label.setFont(font) self.group_desc = QGroupBox("Description", self) layout = QHBoxLayout() layout.addWidget(info_icon) layout.addWidget(self.desc_label) layout.addStretch() layout.addWidget(self.service_status_label) self.group_desc.setLayout(layout) self.editor = CodeEditor(self) self.editor.setup_editor(linenumbers=True, font=font) self.editor.setReadOnly(False) self.group_code = QGroupBox("Source code", self) layout = QVBoxLayout() layout.addWidget(self.editor) self.group_code.setLayout(layout) self.enable_button = QPushButton(get_icon("apply.png"), "Enable", self) self.save_button = QPushButton(get_icon("filesave.png"), "Save", self) self.disable_button = QPushButton(get_icon("delete.png"), "Disable", self) self.refresh_button = QPushButton(get_icon("restart.png"), "Refresh", self) hlayout = QHBoxLayout() hlayout.addWidget(self.save_button) hlayout.addWidget(self.enable_button) hlayout.addWidget(self.disable_button) hlayout.addWidget(self.refresh_button) vlayout = QVBoxLayout() vlayout.addWidget(self.group_desc) vlayout.addWidget(self.group_code) self.html_window = HTMLWindow() vlayout.addWidget(self.html_window) vlayout.addLayout(hlayout) self.setLayout(vlayout) self.current_file = None
def _set_widgets(self): """ Parse operation (function arguments) and create widgets according to the function annotations. Fill with default or current argument values and display the widgets. """ self._clear_widgets() # Retreive operation (function detail), instantiate neccesary widgets package, fun = self._op["module"].rsplit('.', 1) module = import_module(package) self._op["function"] = getattr(module, fun) argspec = inspect.getfullargspec(self._op["function"]) # Create widgets self._labels = [] self._widgets = [] self._none_checkbox_widgets = [] for par_name, annotation in sorted(argspec.annotations.items()): label = QLabel(par_name) font = qtgui.QFont() font.setPointSize(10) label.setFont(font) # find associated widget and functions mapping = {} if "widget" in annotation: mapping["widget"] = widget = getattr(qtgui, annotation["widget"]) mapping["display_func"] = annotation["display_func"] mapping["display_conversion"] = annotation["display_conversion"] mapping["get_func"] = annotation["get_func"] elif "type" in annotation: try: mapping = dict(GenericOperationWidget.type_mapping[annotation["type"]]) except KeyError: print("Can't find wiget for type: {type} for parameter " + "{par_name}".format(type=annotation["type"], par_name=par_name)) continue else: continue # instanciate widget and make display_function callable widget = mapping["widget"]() if not callable(mapping["display_func"]): mapping["display_func"] = widget.__getattribute__(mapping["display_func"]) # save mapping and parameter name for later use widget.mapping = mapping widget.par_name = par_name # create checkbox to allow not to set this parameter checkbox = QCheckBox() checkbox.setChecked(True) checkbox.setToolTip("Set the \"%s\" parameter. If unchecked, the default value is used." % par_name) checkbox.par_name = widget.par_name # Set value of widget according to parameters of the operation try: if "display_conversion" in mapping: display_value = mapping["display_conversion"](self._op["kwargs"][par_name]) else: display_value = self._op["kwargs"][par_name] mapping["display_func"](display_value) except KeyError: checkbox.setChecked(False) self._labels.append(label) self._widgets.append(widget) self._none_checkbox_widgets.append(checkbox) # Add widgets to layout if not self._widgets: self.widget_layout.addWidget(QLabel("No operation parameters")) for i, widget in enumerate(self._widgets): self.widget_layout.addWidget(self._labels[i]) self.widget_layout.addWidget(self._widgets[i]) self.widget_layout.addWidget(self._none_checkbox_widgets[i])
def __init__(self, parent, new_size, old_size, text="", keep_original_size=False): QDialog.__init__(self, parent) intfunc = lambda tup: [int(val) for val in tup] if intfunc(new_size) == intfunc(old_size): self.keep_original_size = True else: self.keep_original_size = keep_original_size self.width, self.height = new_size self.old_width, self.old_height = old_size self.ratio = self.width/self.height layout = QVBoxLayout() self.setLayout(layout) formlayout = QFormLayout() layout.addLayout(formlayout) if text: label = QLabel(text) label.setAlignment(Qt.AlignHCenter) formlayout.addRow(label) self.w_edit = w_edit = QLineEdit(self) w_valid = QIntValidator(w_edit) w_valid.setBottom(1) w_edit.setValidator(w_valid) self.h_edit = h_edit = QLineEdit(self) h_valid = QIntValidator(h_edit) h_valid.setBottom(1) h_edit.setValidator(h_valid) zbox = QCheckBox(_("Original size"), self) formlayout.addRow(_("Width (pixels)"), w_edit) formlayout.addRow(_("Height (pixels)"), h_edit) formlayout.addRow('', zbox) formlayout.addRow(_("Original size:"), QLabel("%d x %d" % old_size)) self.z_label = QLabel() formlayout.addRow(_("Zoom factor:"), self.z_label) # Button box self.bbox = bbox = QDialogButtonBox(QDialogButtonBox.Ok| QDialogButtonBox.Cancel) bbox.accepted.connect(self.accept) bbox.rejected.connect(self.reject) layout.addWidget(bbox) self.w_edit.setText(str(self.width)) self.h_edit.setText(str(self.height)) self.update_widgets() self.setWindowTitle(_("Resize")) w_edit.textChanged.connect(self.width_changed) h_edit.textChanged.connect(self.height_changed) zbox.toggled.connect(self.toggled_no_zoom) zbox.setChecked(self.keep_original_size)
def __init__(self, parent): super().__init__(parent) self.camera = None self.cameraSettings = None self.aquireData = False self.directory = 'N:/4all/mpsd_drive/xtsfasta/Data' layoutWidget = QWidget() layout = QGridLayout() layoutWidget.setLayout(layout) ############### # GUI elements self.openCamBtn = QPushButton('Connect camera') self.startAquBtn = QPushButton('Start aquisiton') self.readoutSpeedCombo = QComboBox() # this really should not be hard coded but received from dll self.readoutSpeedCombo.addItems(["1 MHz", "1.8 MHz", "2.3 MHz", "2.8 MHz", "250 kHz", "500 kHz"]) self.exposureTimeSpin = QSpinBox() self.exposureTimeSpin.setRange(1, 1e6) self.exposureTimeSpin.setValue(1e3) # default exposure 1s self.exposureTimeSpin.setSingleStep(100) self.exposureTimeSpin.setSuffix(' ms') #self.exposureTimeSpin.setValidator(QIntValidator(1, 2**31)) # ms self.binningXCombo = QComboBox() self.binningXCombo.addItems(["No binning", "Binning of 2 columns", "Binning of 4 columns", "Binning of 8 columns", "Binning of 16 columns", "Binning of 32 columns", "Binning of 64 columns", "Binning of 128 columns", "Full horizontal binning"]) self.binningYCombo = QComboBox() self.binningYCombo.addItems(["No binning", "Binning of 2 lines", "Binning of 4 lines", "Binning of 8 lines", "Binning of 16 lines", "Binning of 32 lines", "Binning of 64 lines", "Binning of 128 lines", "Binning of 256 lines"]) self.temperatureSpin = QSpinBox() self.temperatureSpin.setRange(-100, 20) self.temperatureSpin.setValue(-10) self.temperatureSpin.setSuffix('°C') self.updateInterSpin = QSpinBox() self.updateInterSpin.setRange(1, 3600) self.updateInterSpin.setValue(5) self.updateInterSpin.setSuffix(' s') #self.updateInterSpin.setText("2") #self.updateInterEdit.setValidator(QIntValidator(1, 3600)) self.loi = QSpinBox() self.loi.setRange(1, 511) # one pixel less as the camera has self.deltaPixels = QSpinBox() self.deltaPixels.setRange(0, 256) self.autoSave = QCheckBox("Auto save") self.getDirectory = QPushButton('Choose Dir') self.dirPath = QLineEdit(self.directory) self.comment = QPlainTextEdit() ############## # put elements in layout layout.addWidget(self.openCamBtn, 0, 0) layout.addWidget(self.startAquBtn, 0, 1) layout.addWidget(QLabel('readout speed'), 1, 0) layout.addWidget(self.readoutSpeedCombo, 1, 1) layout.addWidget(QLabel('exposure time'), 2, 0) layout.addWidget(self.exposureTimeSpin, 2, 1) layout.addWidget(QLabel('binning X'), 3, 0) layout.addWidget(self.binningXCombo, 3, 1) layout.addWidget(QLabel('binning Y'), 4, 0) layout.addWidget(self.binningYCombo, 4, 1) layout.addWidget(QLabel('temperature'), 5, 0) layout.addWidget(self.temperatureSpin, 5, 1) layout.addWidget(QLabel('update every n-seconds'), 6, 0) layout.addWidget(self.updateInterSpin, 6, 1) layout.addWidget(QLabel('Pixel of interest'), 7, 0) layout.addWidget(self.loi, 7, 1) layout.addWidget(QLabel('Δ pixels'), 8, 0) layout.addWidget(self.deltaPixels, 8, 1) layout.addWidget(self.autoSave, 9, 1) layout.addWidget(self.getDirectory, 10, 0) layout.addWidget(self.dirPath, 10, 1) layout.addWidget(QLabel('Comment:'), 11, 0) layout.addWidget(self.comment, 12, 0, 1, 2) layout.setRowStretch(13, 10) self.addWidget(layoutWidget) ################# # connect elements for functionality self.openCamBtn.released.connect(self.__openCam) self.getDirectory.released.connect(self.__chooseDir) self.temperatureSpin.valueChanged.connect(self.__setTemperature) self.exposureTimeSpin.valueChanged.connect(self.__setCamParameter) self.readoutSpeedCombo.currentIndexChanged.connect(self.__setCamParameter) self.startAquBtn.released.connect(self.__startCurrImageThr) ################ # thread for updating position self.currImage_thread = QThread() # create the QThread self.currImage_thread.start() # This causes my_worker.run() to eventually execute in my_thread: self.currImage_worker = GenericWorker(self.__getCurrImage) self.currImage_worker.moveToThread(self.currImage_thread) self.startAquBtn.setEnabled(False) self.readoutSpeedCombo.setEnabled(False) self.exposureTimeSpin.setEnabled(False) self.binningXCombo.setEnabled(False) self.binningYCombo.setEnabled(False) self.temperatureSpin.setEnabled(False) self.updateInterSpin.setEnabled(False)
def __init__(self, parent): #super(ObjectFT, self).__init__(Qt.Vertical, parent) super().__init__(parent) self.scp = None # variable to hold oscilloscope object self.mutex = QMutex() layoutWidget = QWidget() layout = QGridLayout() layoutWidget.setLayout(layout) self.openDevBtn = QPushButton('Open Osci') # channel stuff self.measCh = QComboBox() self.chSens = QComboBox() self.triggCh = QComboBox() self.frequency = QLineEdit() self.frequency.setValidator(QIntValidator()) self.recordLen = QLineEdit() self.recordLen.setValidator(QIntValidator()) self.delay = QLineEdit() self.delay.setValidator(QDoubleValidator()) # trigger stuff self.triggLevel = QLineEdit() self.triggLevel.setToolTip( 'http://api.tiepie.com/libtiepie/0.5/triggering_scpch.html#triggering_scpch_level' ) self.triggLevel.setText( '0.5' ) # init value otherwise there's trouble with signal changing index of sensitivity self.triggLevel.setValidator(QDoubleValidator(0., 1., 3)) self.hystereses = QLineEdit() self.hystereses.setText('0.05') self.hystereses.setToolTip( 'http://api.tiepie.com/libtiepie/0.5/triggering_scpch.html#triggering_scpch_hysteresis' ) self.hystereses.setValidator(QDoubleValidator(0., 1., 3)) self.triggKind = QComboBox() # do averages self.averages = QSpinBox() self.averages.setValue(1) self.averages.setRange(1, 10000) # put layout together layout.addWidget(self.openDevBtn, 0, 0) layout.addWidget(QLabel('Measuring Ch'), 1, 0) layout.addWidget(self.measCh, 1, 1) layout.addWidget(QLabel('Ch sensitivity'), 2, 0) layout.addWidget(self.chSens, 2, 1) layout.addWidget(QLabel('Sample freq. (kHz)'), 3, 0) layout.addWidget(self.frequency, 3, 1) layout.addWidget(QLabel('Record length'), 4, 0) layout.addWidget(self.recordLen, 4, 1) layout.addWidget(QLabel('Delay'), 5, 0) layout.addWidget(self.delay, 5, 1) layout.addWidget(QLabel('Trigger Ch'), 6, 0) layout.addWidget(self.triggCh, 6, 1) layout.addWidget(QLabel('Trigger Level (%)'), 7, 0) layout.addWidget(self.triggLevel, 7, 1) layout.addWidget(QLabel('Hystereses'), 8, 0) layout.addWidget(self.hystereses, 8, 1) layout.addWidget(QLabel('Trigger kind'), 9, 0) layout.addWidget(self.triggKind, 9, 1) layout.addWidget(QLabel('Averages'), 10, 0) layout.addWidget(self.averages, 10, 1) layout.setRowStretch(11, 10) layout.setColumnStretch(2, 10) self.addWidget(layoutWidget) # connect UI to get things working self.openDevBtn.released.connect(self.openDev) self.chSens.currentIndexChanged.connect(self._changeSens) self.frequency.returnPressed.connect(self._changeFreq) self.recordLen.returnPressed.connect(self._changeRecordLength) self.triggCh.currentIndexChanged.connect(self._changeTrigCh) self.triggLevel.returnPressed.connect(self._triggLevelChanged) self.triggLevel.textChanged.connect(self._check_state) self.hystereses.returnPressed.connect(self._setHystereses) self.hystereses.textChanged.connect(self._check_state)
def __init__(self, parent): #super(ObjectFT, self).__init__(Qt.Vertical, parent) super().__init__(parent) self.meter = None self.collectData = True # bool for data collection thread self.avgData = Queue() # need data for averaging and set for holding all self.measure = False self.runDataThr = True self.measureData = [] self.startTime = None layoutWidget = QWidget() layout = QGridLayout() layoutWidget.setLayout(layout) ############## # gui elements self.ipEdit = QLineEdit() rx = QRegExp("^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$") self.ipEdit.setValidator(QRegExpValidator(rx)) self.ipEdit.setText('127.0.0.1') self.portEdit = QLineEdit() self.portEdit.setValidator(QIntValidator(1, 65535, self)) self.portEdit.setText('5000') self.connectBtn = QPushButton('Connect') self.avgSpin = QSpinBox() self.avgSpin.setValue(1) self.avgSpin.setRange(1, 10000) self.currValDisp = QLabel('0.0') self.startMeasBtn = QPushButton('Start aq') self.stopMeasBtn = QPushButton('Stop aq') ############## # put layout together layout.addWidget(QLabel('IP Address:'), 0, 0) layout.addWidget(self.ipEdit, 1, 0) layout.addWidget(QLabel('Port:'), 0, 1) layout.addWidget(self.portEdit, 1, 1) layout.addWidget(self.connectBtn, 2, 1) layout.addWidget(QLabel('Averages'), 4, 0) layout.addWidget(self.avgSpin, 5, 0) layout.addWidget(self.currValDisp, 5, 1) layout.addWidget(self.startMeasBtn, 6, 0) layout.addWidget(self.stopMeasBtn, 6, 1) layout.setRowStretch(7, 10) self.addWidget(layoutWidget) ############## # Network stuff self.tcpClient = QtNetwork.QTcpSocket() self.tcpClient.readyRead.connect(self.__getSocketData) self.tcpClient.error.connect(lambda x: print(x)) ############## # make button and stuff functional self.connectBtn.released.connect(self.connectMeter) self.avgSpin.valueChanged.connect(self.changeAverage) self.startMeasBtn.released.connect(self._startMeasure) self.stopMeasBtn.released.connect(self._stopMeasure) ############## # thread for getting data from socket self.updateAvgTxt.connect(self.__updateAvgTxt) self.dataAq_Thr = QThread() self.dataAq_Thr.start() self.dataAq_worker = GenericWorker(self.__getData) self.dataAq_worker.moveToThread(self.dataAq_Thr)
def __init__(self, parent): #super(ObjectFT, self).__init__(Qt.Vertical, parent) super().__init__(parent) self.stage = None self.offset = 0. # offset from 0 where t0 is (mm) self.newOff = 0. self.stageRange = (0, 0) layoutWidget = QWidget() layout = QGridLayout() layoutWidget.setLayout(layout) # put layout together self.openStageBtn = QPushButton("Open stage") self.initStageBtn = QPushButton("Init stage") #absolute move #current position self.currentPos = QLabel('') #self.currentPos.setValidator(QDoubleValidator()) #relative move (mm) self.deltaMove_mm = QLineEdit() self.deltaMove_mm.setText('0') self.deltaMove_mm.setValidator(QDoubleValidator()) self.deltaMovePlus_mm = QPushButton('+') self.deltaMoveMinus_mm = QPushButton('-') #relative move (fs) self.deltaMove_fs = QLineEdit() self.deltaMovePlus_fs = QPushButton('+') self.deltaMoveMinus_fs = QPushButton('-') #velocity self.velocityLabel = QLabel('Velocity:') self.velocity = QSlider(Qt.Horizontal) self.velocity.setMinimum(0) self.velocity.setMaximum( 2000) # unit in µm; TODO: try to get max vel. from controller # scan from (fs) self.scanFrom = QLineEdit() self.scanFrom.setText('-100') self.scanFrom.setValidator(QIntValidator()) # scan to (fs) self.scanTo = QLineEdit() self.scanTo.setText('100') self.scanTo.setValidator(QIntValidator()) # scan stepsize (fs) self.scanStep = QLineEdit() self.scanStep.setText('10') self.scanStep.setValidator(QDoubleValidator()) # center here button self.centerBtn = QPushButton('Center here') self.centerBtn.setToolTip('Center scan at current stage position') self.startScanBtn = QPushButton("Start scan") self.stopScanBtn = QPushButton("Stop scan") self.niceBtn = QPushButton('Make it nice') # spacer line hLine = QFrame() hLine.setFrameStyle(QFrame.HLine) hLine.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Expanding) # put layout together layout.addWidget(self.openStageBtn, 0, 0) layout.addWidget(self.initStageBtn, 0, 1) layout.addWidget(QLabel("Current pos (mm):"), 1, 0) layout.addWidget(self.currentPos, 1, 1) layout.addWidget(self.velocityLabel, 2, 0) layout.addWidget(self.velocity, 3, 0, 1, 2) layout.addWidget(QLabel('Move relative (mm)'), 4, 0) layout.addWidget(self.deltaMove_mm, 5, 0, 1, 2) layout.addWidget(self.deltaMoveMinus_mm, 6, 0) layout.addWidget(self.deltaMovePlus_mm, 6, 1) layout.addWidget(QLabel('Move relative (fs)'), 7, 0) layout.addWidget(self.deltaMove_fs, 8, 0, 1, 2) layout.addWidget(self.deltaMoveMinus_fs, 9, 0) layout.addWidget(self.deltaMovePlus_fs, 9, 1) layout.addWidget(hLine, 10, 0, 1, 2) layout.addWidget(QLabel('Scan from (fs)'), 11, 0) layout.addWidget(self.scanFrom, 11, 1) layout.addWidget(QLabel('Scan to (fs)'), 12, 0) layout.addWidget(self.scanTo, 12, 1) layout.addWidget(QLabel('Stepsize (fs)'), 13, 0) layout.addWidget(self.scanStep, 13, 1) layout.addWidget(self.startScanBtn, 14, 0) layout.addWidget(self.stopScanBtn, 14, 1) layout.addWidget(self.centerBtn, 15, 1) layout.addWidget(self.niceBtn, 16, 1) layout.setRowStretch(17, 10) layout.setColumnStretch(2, 10) self.addWidget(layoutWidget) # make button and stuff functional self.openStageBtn.released.connect(self.connectStage) self.initStageBtn.released.connect(self.initStage) self.scanFrom.returnPressed.connect(self._xAxeChanged) self.scanTo.returnPressed.connect(self._xAxeChanged) self.centerBtn.released.connect(self._centerHere) self.deltaMovePlus_mm.released.connect( lambda x=1: self.moveRel_mm(float(self.deltaMove_mm.text()))) self.deltaMoveMinus_mm.released.connect( lambda x=-1: self.moveRel_mm(float(self.deltaMove_mm.text()), x)) ################ # thread for updating position #self.currPosThr = GenericThread(self.__getCurrPos) self.updateCurrPos.connect(self.__updateCurrPos) self.currPos_thread = QThread() # create the QThread self.currPos_thread.start() # This causes my_worker.run() to eventually execute in my_thread: self.currPos_worker = GenericWorker(self.__getCurrPos) self.currPos_worker.moveToThread(self.currPos_thread)