def fromUi(*args, **kwargs): """ Returns a Qt object constructed using loadUiType based on its arguments. All QWidget objects in the form class are set in the returned object for easy accessability. """ form_class, base_class = loadUiType(*args, **kwargs) widget = base_class() form = form_class() form.setupUi(widget) form.retranslateUi(widget) for name in dir(form): element = getattr(form, name) if isinstance(element, QtGui.QWidget): setattr(widget, name, element) return widget
d = HaasoscopeLibQt.Haasoscope() d.construct() #Some other options #d.serport="COM7" # the name of the serial port on your computer, connected to Haasoscope, like /dev/ttyUSB0 or COM8, leave blank to detect automatically! d.serialdelaytimerwait = serialdelaytimerwait #50 #100 #150 #300 # 600 # delay (in 2 us steps) between each 32 bytes of serial output (set to 600 for some slow USB serial setups, but 0 normally) #d.dolockin=True # whether to calculate the lockin info on the FPGA and read it out (off by default) #d.db=True #turn on debugging app = QtGui.QApplication.instance() standalone = app is None if standalone: app = QtGui.QApplication(sys.argv) # Define main window class from template WindowTemplate, TemplateBaseClass = loadUiType("Haasoscope.ui") class MainWindow(TemplateBaseClass): def __init__(self): TemplateBaseClass.__init__(self) # Create the main window self.ui = WindowTemplate() self.ui.setupUi(self) self.ui.runButton.clicked.connect(self.dostartstop) self.ui.actionRecord.triggered.connect(self.record) self.ui.verticalSlider.valueChanged.connect(self.triggerlevelchanged) self.ui.verticalSlider2.valueChanged.connect(self.triggerlevel2changed) self.ui.thresh2Check.clicked.connect(self.thresh2) self.ui.horizontalSlider.valueChanged.connect(self.triggerposchanged)
import sys import time import os import numpy as np import pyqtgraph as pg from pyqtgraph.Qt import QtWidgets, QtCore, loadUiType pg.setConfigOption('background', 'w') pg.setConfigOption('foreground', 'k') BLUE = pg.mkPen('#1f77b4') path = os.path.dirname(os.path.abspath(__file__)) uiFile = os.path.join(path, 'DateAxisItem_QtDesigner.ui') Design, _ = loadUiType(uiFile) class ExampleApp(QtWidgets.QMainWindow, Design): def __init__(self): super().__init__() self.setupUi(self) now = time.time() # Plot random values with timestamps in the last 6 months timestamps = np.linspace(now - 6 * 30 * 24 * 3600, now, 100) self.curve = self.plotWidget.plot(x=timestamps, y=np.random.rand(100), symbol='o', symbolSize=5, pen=BLUE) # 'o' circle 't' triangle 'd' diamond '+' plus 's' square
def loadUiFile(uiFile): uiPath = os.path.join(uiBasePath, uiFile) uiClasses = loadUiType(uiPath) # form class and Qt base class. return uiClasses
def loadUiFile(uiFile): uiPath = os.path.join(uiBasePath, uiFile) # form class and Qt base class. return loadUiType(uiPath)
# -*- coding: utf-8 -*- """ pyqtgraph widget with UI template created with Qt Designer """ import numpy as np import sys, time from serial import SerialException import pyqtgraph as pg from pyqtgraph.Qt import QtCore, QtWidgets, QtGui, loadUiType import h5py # Define fft window class from template FFTWindowTemplate, FFTTemplateBaseClass = loadUiType("HaasoscopeFFT.ui") class FFTWindow(FFTTemplateBaseClass): def __init__(self): FFTTemplateBaseClass.__init__(self) self.ui = FFTWindowTemplate() self.ui.setupUi(self) self.ui.plot.setLabel('bottom', 'Freq (MHz)') self.ui.plot.setLabel('left', '|Y(freq)|') self.ui.plot.showGrid(x=True, y=True, alpha=1.0) self.ui.plot.setRange(xRange=(0.0, 65.0)) self.ui.plot.setBackground('w') c = (10, 10, 10) self.fftpen = pg.mkPen(color=c) # add linewidth=0.5, alpha=.5 self.fftline = self.ui.plot.plot(pen=self.fftpen, name="fft_plot") self.fftlastTime = time.time() - 10 self.fftyrange = 1 # Define persist window class from template