def __init__(self): self.canvasscaledspectrogram = CanvasScaledSpectrogram() self.T = 0. self.dT = 1. self.jitter_s = 0. self.last_data_time = 0. self.isPlaying = True self.sfft_rate_frac = Fraction(1, 1) self.frequency_resampler = Frequency_Resampler() self.resampler = Online_Linear_2D_resampler() self.timer = QtCore.QElapsedTimer() self.timer.start() self.last_time = 0.
def nearestSnaps(self, snap_dist, excludePt=None): '''Return a list of (equally) closest snap-tuples, in scene coordinates. Parameters are in scene coordinates. Returned tuples are (distance squared, QPointF p from self, QPointF q from other) ''' # This never seems to take more than a couple dozen ms, but nevertheless # performance is very sluggish, because Qt5 sends all mouse events # without compression no matter how long it takes to respond. search_timer = QtCore.QElapsedTimer() search_timer.start() snap_margins = QtCore.QMarginsF(snap_dist * 1.001, snap_dist * 1.001, snap_dist * 1.001, snap_dist * 1.001) nearest_dist2 = snap_dist**2 # Use squared distances to avoid calling sqrt nearest = [] # list of nearby pairs of points # It's distinctly faster to let QGraphicsScene compare each child tile with # other tiles than to ask it to compare all child points with other tiles, # though this still ends up O(n*n) when dragging many tiles over many tiles. for child in self.childItems(): snap_search_rect = child.sceneBoundingRect().marginsAdded( snap_margins) nearby_items = self.scene().items(snap_search_rect) nearby_tiles = [ it for it in nearby_items if hasattr(it, "sceneSnapPoints") and not it.isSelected() ] if nearby_tiles: self._log.trace('{} nearby tiles', len(nearby_tiles)) for other_tile in nearby_tiles: for p in child.sceneSnapPoints(): assert isinstance(p, QtCore.QPointF) if excludePt is None or QtCore.QLineF( p, excludePt).length() > snap_dist / 100.0: for q in other_tile.sceneSnapPoints(): assert isinstance(q, QtCore.QPointF) if excludePt is None or QtCore.QLineF( q, excludePt).length( ) > snap_dist / 100.0: pq = q - p pq2 = pq.x()**2 + pq.y()**2 if pq2 <= nearest_dist2: #assert pq.x() <= snap_dist #assert pq.x() >= -snap_dist #assert pq.y() <= snap_dist #assert pq.y() >= -snap_dist if pq2 < nearest_dist2: nearest_dist2 = pq2 nearest = [] # TODO: shrink snap_margins ? assert isinstance(q, QtCore.QPointF) # ** BUGFIX ** # There appears to be a bug such that if I do not make a copy of q here, # it sometimes mysteriously changes by the end of the function. # Bug was seldom if ever visible under Linux, Windows, or OS 10.10 # Debugged under OS X 10.14, Python 3.8.3, PyQt 5.15.2, 2021-Feb nearest.append((pq2, QtCore.QPointF(p), QtCore.QPointF(q))) #self._log.trace('nearest = {}', nearest) if search_timer.hasExpired(250): self._log.info('aborting slow search: {} ms', search_timer.elapsed()) return [] #self._log.info('{} children searched in {} ms', len(self.childItems()), search_timer.elapsed()) #self._log.trace('final nearest = {}', nearest) #for pq2,p,q in nearest: # assert isinstance(p, QtCore.QPointF) # assert isinstance(q, QtCore.QPointF) # pq = q - p # assert pq.x() <= snap_dist # assert pq.x() >= -snap_dist # assert pq.y() <= snap_dist # assert pq.y() >= -snap_dist return nearest
def __init__(self, parent=None, difficulty=1.5, practice=10): QtWidgets.QWidget.__init__(self, parent) screen = QtWidgets.QDesktopWidget().screenGeometry() self.setGeometry(0, 0, 900, 700) self.move(screen.width() / 2 - self.width() / 2, screen.height() / 2 - self.height() / 2) self.genStim(practice) self.tmStim = QtCore.QTimer(self) self.tmStim.timeout.connect(self.StimShow) self.tmCue = QtCore.QTimer(self) self.tmCue.timeout.connect(self.CueShow) self.tmBlank = QtCore.QTimer(self) self.tmBlank.timeout.connect(self.BlankShow) self.lbCue = QtWidgets.QLabel(self) self.lbCue.setFixedSize(300, 300) self.lbCue.move((self.width() - self.lbCue.width()) / 2, (150 - self.lbCue.height() / 2)) self.lbCue.setText("+") self.lbCue.setAlignment(Qt.Qt.AlignCenter) self.lbCue.setFont(QtGui.QFont("Arial", 20)) self.lbCue.hide() self.sounds = { "C": QtMultimedia.QSound("highpitch.wav"), "W": QtMultimedia.QSound("lowpitch.wav") } #self.tmTarget = QtCore.QTimer(self) #self.tmTarget.timeout.connect(self.TargetShow) self.lbIntro = QtWidgets.QLabel(self) self.lbIntro.setTextFormat(Qt.Qt.RichText) self.lbIntro.setText( '<pre> <font size=18>欢迎参加数量计算练习实验</font><br /> <br />' ' 计算练习包括了加法和减法,每次练习开始时会提示<span style="color: #ff0000;">加法</span>还是' '<span style="color: #ff0000;">减法</span>计算。<br /> 加法计算时,首先在左侧呈现一组散点,' '随后移动至中间区域,之后再右侧呈现一组<br />散点,随后也移动到中间区域。<br /> 减法计算时,' '首先在左侧呈现一组散点,随后移动至中央区域,之后从该区域移出若<br />干散点。<br />' ' 两者均要求判断在中间区域的<span style="color: #ff0000;">散点数量(目标)</span>。在散点呈现之后,' '会在下方出现备选答案。<br />分成两种条件,如只出现一组散点,则要求判断数量的多少,如比目标少,' '则按<span style="color: #ff0000;">"F"键</span>,<br />多则按<span style="color: #ff0000;">"J"键</span>。' '如出现两组散点,怎要求判断那一侧与目标相同,左侧按"F"键,右侧按"J"键。<br /><br /> 理解无误后,按回车键开始"</pre>' ) self.lbIntro.setFont(QtGui.QFont("Arial", 20)) self.lbIntro.setGeometry(0, 0, 800, 600) self.lbIntro.move(self.width() / 2 - self.lbIntro.width() / 2, self.height() / 2 - self.lbIntro.height() / 2) self.lbIntro.show() self.round = 0 self.bStart = False self.bResponse = False self.difficulty = difficulty #设置任务难度,即目标散点和备选散点之间的比率,数值越高难度越小 self.ResponseData = [] self.iData = {} self.Rt = QtCore.QElapsedTimer()
def __init__(self, parent=None): fmt = QtOpenGL.QGLFormat() fmt.setVersion(3, 3) fmt.setProfile(QtOpenGL.QGLFormat.CoreProfile) fmt.setSampleBuffers(True) self.timer = QtCore.QElapsedTimer() super().__init__(fmt, parent=parent)
def start(self): # Init request flag. self.request = False self.controlling = False self.alive = True # Start a timer for PID. self.timer = QtCore.QElapsedTimer() self.timer.start() # Init PID. self.pid = PID(timestamp=self.timer.elapsed()) # Load tasks from NI-MAX. self.task_ai = nidaqmx.system.storage.persisted_task.PersistedTask('TaskTemp').load() self.task_co = nidaqmx.system.storage.persisted_task.PersistedTask('TaskPow').load() self.task_do = nidaqmx.system.storage.persisted_task.PersistedTask('TaskDir').load() # Start tasks. try: self.task_ai.start() self.task_do.control(nidaqmx.constants.TaskMode.TASK_RESERVE) self.task_co.control(nidaqmx.constants.TaskMode.TASK_RESERVE) self.task_do.start() self.task_co.start() except Exception as err: print(err)
def createTimer(self): self.main_timer = QtCore.QTimer() self.timer = QtCore.QElapsedTimer() self.main_timer.timeout.connect(self.main_loop) self.main_timer.start(30) self.timer.start()
class SharedData(QtCore.QObject): bufsize = 1024 buffers = 4 blksize = bufsize * buffers timer1 = QtCore.QElapsedTimer() current_frame = QtCore.pyqtSignal(object) frame_processor_finished = QtCore.pyqtSignal() dispatcher_finished = QtCore.pyqtSignal() MyThreadPool = QtCore.QThreadPool() threadcount = MyThreadPool.maxThreadCount() loopcounter = [0] * threadcount stream_URI = getURI() timestart = 0 timeend = 0 errors = False framequeue = [] # or Queue() loopdelay = [0.0010, 0.0020] width = 640 height = 480 recording = False fps = 10 audio_enabled = False blank_image = False videoframe = None IsStream = False def __init__(self, parent=None): QtCore.QObject.__init__(self) super(self.__class__, self).__init__()
def __init__(self, format=None, shared=False): super().__init__() self.profile = QtGui.QOpenGLVersionProfile() self.profile.setVersion(2, 1) self.palette = QtGui.QImage("../../../Screenshots/palette.ppm") self.image_width = 800 self.image_height = 600 self.timer = QtCore.QElapsedTimer() self.timer.start() self.iter = 60 if format == None: self.format = QtGui.QSurfaceFormat() self.format.setVersion(4, 5) self.format.setSamples(8) self.format.setProfile(QtGui.QSurfaceFormat.CompatibilityProfile) else: self.format = format # If local context must be shared with another context, we will # create it later (see main.py). if not shared: self.context = QtGui.QOpenGLContext() self.context.setFormat(self.format) self.context.create() else: self.context = None self.surface = QtGui.QOffscreenSurface() self.surface.setFormat(self.format) self.surface.create() self.init = False
def __init__(self): super(MainWindow, self).__init__() self.ui = Ui_MainWindow() self.ui.setupUi(self) self.serial = QSerialPort(self) self.timer = QtCore.QElapsedTimer() self.graphInit() self.getAvaliablePorts() self.ui.pushButton_Get.clicked.connect(self.getOnce_slot) self.ui.pushButton_Start.clicked.connect(self.start_slot) self.ui.pushButton_Stop.clicked.connect(self.stop_slot) self.serial.readyRead.connect(self.serialRead_slot) self.data_isReady_signal.connect(self.plotUpdate) self.get_data_signal.connect(self.getOnce_slot) average = [] for i in range(1, 10): average.append(str(i)) for average_ in average: entry = QAction(average_, self) self.ui.menuAverage.addAction(entry) entry.triggered.connect(lambda Val, average_to_set=average_: self. average_set(average_to_set))
def __init__(self, participant, experiments, delay, app): super().__init__() self.app = app self.participant = participant self.experiments = experiments self.delay = int(delay) self.counter = -1 self.cleanwindow = False self.timer = QtCore.QElapsedTimer() self.timer.start() self.player = QtMultimedia.QSound("whitenoise.wav") self.initUI() self.colours = ["Red", "Green"] self.englishWords = [ "tree", "egg", "file", "mushroom", "list", "example", "rectangle", "holy", "adventure", "chair", "mouth", "bottle", "keyboard" ] self.germanWords = [ "baum", "ei", "datei", "pilz", "liste", "beispiel", "rechteck", "heilig", "abenteuer", "stuhl", "mund", "flasche", "tastatur" ] self.log = [[ "PID", "Stimulus", "Attentive", "Distraction", "Key", "Correct", "Timestamp", "Reactiontime" ]] self.stimulus = "Experiment start" self.attentive = False self.distraction = False
def __init__(self, parent=None): super(OwnImageWidget, self).__init__(parent) #self.installEventFilter(self) self.audio_enabled = False self.setAcceptDrops(False) self.name = parent.objectName() self.image = None self.startpos = QtCore.QPoint(0, 0) self.releasepos = QtCore.QPoint(0, 0) self.pos = QtCore.QPoint(0, 0) self.clipper = QtCore.QRect(self.startpos, self.releasepos) self.pen = QtGui.QColor(255, 34, 255, 50) self.recording = False self.last_event = None self.editing = None self.retainimage = False self.clipzoom = False self.retainclip = False self.current_event = None self.retainimage = False self.SharedData = None self.WidgetData = WidgetData(self) #self.clicked.connect(self.buttonWasPressed) self.t = QtCore.QElapsedTimer() self.qp = QtGui.QPainter()
def __init__(self): fmt = QtOpenGL.QGLFormat() fmt.setVersion(3, 3) fmt.setProfile(QtOpenGL.QGLFormat.CoreProfile) fmt.setSampleBuffers(True) self.timer = QtCore.QElapsedTimer() super(QGLControllerWidget, self).__init__(fmt, None)
def __init__(self, major=4, minor=4): fmt = QtOpenGL.QGLFormat() fmt.setVersion(major, minor) fmt.setProfile(QtOpenGL.QGLFormat.CoreProfile) fmt.setSampleBuffers(True) self.timer = QtCore.QElapsedTimer() super(_window, self).__init__(fmt, None) self.paintGL = None
def __init__(self): self.time = None # [s] self.reading_1 = np.nan # Keep track of the obtained DAQ rate self.update_counter_DAQ = 0 self.obtained_DAQ_rate_Hz = np.nan self.QET_rate = QtCore.QElapsedTimer() self.rate_accumulator = 0
def __init__(self, protocol_xml_path="default_config.xml", command_xml_path="default_config.xml", verbose=False, pumpType='peristaltic'): super(KilroyProtocols, self).__init__() # Initialize internal attributes self.verbose = verbose self.protocol_xml_path = protocol_xml_path self.command_xml_path = command_xml_path self.protocol_names = [] self.protocol_commands = [] # [Instrument Type, command_info] self.protocol_durations = [] self.num_protocols = 0 self.status = [-1, -1] # Protocol ID, command ID within protocol self.issued_command = [] self.received_message = None self.pumpType = pumpType print( "----------------------------------------------------------------------" ) # Create instance of ValveCommands class self.valveCommands = ValveCommands(xml_file_path=self.command_xml_path, verbose=self.verbose) # Connect valve command issue signal self.valveCommands.change_command_signal.connect( self.issueValveCommand) # Create instance of PumpCommands class self.pumpCommands = PumpCommands(xml_file_path=self.command_xml_path, verbose=self.verbose, pumpType=pumpType) # Connect pump commands issue signal self.pumpCommands.change_command_signal.connect(self.issuePumpCommand) # Create GUI self.createGUI() # Load configurations self.loadProtocols(xml_file_path=self.protocol_xml_path) # Create protocol timer--controls when commands are issued self.protocol_timer = QtCore.QTimer() self.protocol_timer.setSingleShot(True) self.protocol_timer.timeout.connect(self.advanceProtocol) # Create elapsed time timer--determines time between command calls self.elapsed_timer = QtCore.QElapsedTimer() self.poll_elapsed_time_timer = QtCore.QTimer() self.poll_elapsed_time_timer.setInterval(1000) self.poll_elapsed_time_timer.timeout.connect(self.updateElapsedTime)
def nearestSnaps(self, snap_dist, excludePt=None): '''Return a list of (equally) closest snap-tuples, in scene coordinates. Parameters are in scene coordinates. Returned tuples are (distance squared, p from self, q from other) ''' # This never seems to take more than a couple dozen ms, but nevertheless # performance is very sluggish, because Qt5 sends all mouse events # without compression no matter how long it takes to respond. search_timer = QtCore.QElapsedTimer() search_timer.start() snap_margins = QtCore.QMarginsF(snap_dist, snap_dist, snap_dist, snap_dist) nearest_dist2 = snap_dist * snap_dist # Use squared distances to avoid calling sqrt nearest = [] # list of nearby pairs of points # It's distinctly faster to let QGraphicsScene compare each child tile with # other tiles than to ask it to compare all child points with other tiles, # though this still ends up O(n*n) when dragging many tiles over many tiles. for child in self.childItems(): snap_search_rect = child.sceneBoundingRect().marginsAdded( snap_margins) nearby_items = self.scene().items(snap_search_rect) nearby_tiles = [ it for it in nearby_items if hasattr(it, "sceneSnapPoints") and not it.isSelected() ] if nearby_tiles: self._log.trace('{} nearby tiles', len(nearby_tiles)) #child_scenePath = child.mapToScene(child.snapShape()) #child_sceneVertices = pathVertices(child_scenePath) for other_tile in nearby_tiles: #other_scenePath = other_tile.mapToScene(other_tile.snapShape()) for p in child.sceneSnapPoints(): if excludePt is None or QtCore.QLineF( p, excludePt).length() > snap_dist / 100.0: for q in other_tile.sceneSnapPoints( ): #pathVertices(other_scenePath): if excludePt is None or QtCore.QLineF( q, excludePt).length( ) > snap_dist / 100.0: pq = p - q pq2 = pq.x()**2 + pq.y()**2 if pq2 <= nearest_dist2: if pq2 < nearest_dist2: nearest_dist2 = pq2 nearest = [ n for n in nearest if n[0] <= nearest_dist2 ] # TODO: shrink snap_margins ? nearest.append((pq2, p, q)) if search_timer.hasExpired(250): self._log.info('aborting slow search: {} ms', search_timer.elapsed()) return [] #self._log.info('{} children searched in {} ms', len(self.childItems()), search_timer.elapsed()) return nearest
def __init__(self, logger, parent=None): self._shape = None self._log = logger super().__init__(parent=parent) self.setFlags(self.flags() | QtWidgets.QGraphicsItem.ItemIsFocusable | QtWidgets.QGraphicsItem.ItemIsSelectable | QtWidgets.QGraphicsItem.ItemIsMovable #| QtWidgets.QGraphicsItem.ItemClipsToShape | QtWidgets.QGraphicsItem.ItemSendsGeometryChanges) self._drag_timer = QtCore.QElapsedTimer() self.initDragXform()
class WidgetData(QtCore.QObject): timer1 = QtCore.QElapsedTimer() audio_finished = QtCore.pyqtSignal() recorder_finished = QtCore.pyqtSignal() image = None scale = 0 image = None clipart = None event = None save_dir = os.getcwd() full_image_path = None filename = None counter = 0 def __init__(self, parent=None): QtCore.QObject.__init__(self) super(self.__class__, self).__init__()
def populateTable(self, mode): if mode == 'widget': self.tablewidget.clear() self.tablewidget.setRowCount(self.spinbox.value()) self.tablewidget.setColumnCount(20) else: model = self.table.model() if model is not None: self.table.setModel(None) model.deleteLater() if len(self._data) != self.spinbox.value(): del self._data[:] rows = list(range(self.spinbox.value())) shuffle(rows) for row in rows: items = [] for column in range(20): items.append('(%d, %d)' % (row, column)) self._data.append(items) timer = QtCore.QElapsedTimer() timer.start() if mode == 'widget': self.tablewidget.setSortingEnabled(False) for row, items in enumerate(self._data): for column, text in enumerate(items): item = QTableWidgetItem(text) self.tablewidget.setItem(row, column, item) self.tablewidget.sortByColumn(0, QtCore.Qt.AscendingOrder) else: self.table.setSortingEnabled(False) if mode == 'custom': # for item in self._data: # print(item) model = TableModel(self._data, self.table) elif mode == 'standard': model = QStandardItemModel(self.table) for row in self._data: items = [] for column in row: items.append(QtGui.QStandardItem(column)) model.appendRow(items) self.table.setModel(model) self.table.setSortingEnabled(True) self.table.sortByColumn(0, QtCore.Qt.AscendingOrder) print('%s: %.3g seconds' % (mode, timer.elapsed() / 1000))
def __init__(self, config): # Create the format fmt = QtOpenGL.QGLFormat() fmt.setVersion(4, 3) fmt.setProfile(QtOpenGL.QGLFormat.CoreProfile) fmt.setSampleBuffers(True) fmt.setSwapInterval(1) # Set the format in the parent class super().__init__(fmt, None) self.framerate = config.framerate self.skip_ms = 1000.0 / self.framerate # Max ms a frame can take to work out to be the desired framerate self.fps = self.framerate # Tracks the current FPS # Store the default window title and set it self.window_title = "JackIT 2.0!" self.setWindowTitle(self.window_title) # Set a fixed size so the window size cannot be changed during the game self.setFixedSize(config.width, config.height) # Put the main window in the middle of the screen screen = QtWidgets.QDesktopWidget().screenGeometry(-1) self.move((screen.width() - config.width) // 2, (screen.height() - config.height) // 2) # Start the game timer. Tracks elapsed time self.timer = QtCore.QElapsedTimer() self.timer.start() self.prev_time = self.timer.elapsed() # True if development mode is enabled. False otherwise. self.dev_mode = config.is_development_mode() # Get the game engine self.game_engine = get_game_engine() # Prepare to display the FPS and playtime int he window titles if self.dev_mode: self.setWindowTitle(self.window_title + " - FPS: 0 Playtime: 0") self.fpstimer = QtCore.QTimer() self.fpstimer.timeout.connect(self.fps_display) self.fpstimer.start(1000)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self._play_queue_thread = QtCore.QThread(self) self.play_queue = PlayQueueManager() self.play_queue.moveToThread(self._play_queue_thread) self.update_timeline.connect(self.play_queue.update) self._play_queue_thread.start() self.timeline_timer = QtCore.QElapsedTimer() self.last_playback_time = 0 self.play_queue.new_item.connect(self.append_item) self.play_queue.new_selection.connect(self._new_active_item) self.play_queue.new_queue.connect(self._replace_playlist) self.play_queue.updated_queue.connect(self._consolidate_playlist) self.play_queue.removed_index.connect(self._remove_item) self.play_queue.working.connect(self.working) self.play_queue.finished.connect(self.finished) self.enqueue.connect(self.play_queue.enqueue) self.create_play_queue.connect(self.play_queue.create) self.select.connect(self.play_queue.select)
def __init__(self): super(self.__class__, self).__init__() self.DIALMAX = 400 self.DIALMIN = 0 self.DIALINITVALUE = 500 self.LCDINITVALUE = 1.0 self.LCDDIGITSCOUNT = 5 self.DIALLCDREL = 100 self.SETTINGSFILE = "LocalLaplaceOpenCVQt.ini" self.DBNAME = "LocalLaplaceOpenCVQt2.db3" self.kSigmaR = 0.8 self.kAlpha = 0.2 self.kBeta = 0.5 self.inputFileName = "" self.ostatnioOtwieraneMax = 4 self.ostatnioOtwieraneActions = [] self.pixmapObrazWejsciowy = QtGui.QPixmap() self.pixmapObrazWyjsciowy = QtGui.QPixmap() self.sliderScale = QtWidgets.QSlider(QtCore.Qt.Horizontal) self.skalaObrazuWejsciowego = 100 self.LPLevels = 0 self.timer = QtCore.QElapsedTimer() self.timertotal = QtCore.QElapsedTimer() self.db = QtSql.QSqlDatabase() self.dbOpenOk = False self.setWindowIcon(QtGui.QIcon('LocalLaplaceOpenCVQtPy.ico')) self.setupUi(self) self.groupScale.setLayout(self.create_slider_skalowanie()) self.sliderScale.valueChanged.connect(self.slider_scale_value_changed) self.actionOtworz.triggered.connect(self.otworz_plik_wejsciowy) self.actionZapiszSesje.triggered.connect( self.action_zapisz_sesje_triggered) self.wowe = None self.actionWyjscie.triggered.connect(self.show_wyjscie) self.wwy = None self.quality_results = { 'BRISQUE': None, 'MSE': None, 'PSNR': None, 'SSIM': None, 'GMSD': None } # self.quality_maps = {'MSE': None, 'PSNR': None, 'SSIM': None, 'GMSD': None} self.dialAlpha.setNotchesVisible(True) self.dialAlpha.setMaximum(self.DIALMAX) self.dialAlpha.setMinimum(self.DIALMIN) self.dialAlpha.setValue(self.DIALINITVALUE) self.lcdNumberAlpha.display(self.LCDINITVALUE) self.lcdNumberAlpha.setNumDigits(self.LCDDIGITSCOUNT) self.dialAlpha.valueChanged.connect(self.wyswietl_lcd_alpha) self.dialBeta.setNotchesVisible(True) self.dialBeta.setMaximum(self.DIALMAX) self.dialBeta.setMinimum(self.DIALMIN) self.dialBeta.setValue(self.DIALINITVALUE) self.lcdNumberBeta.display(self.LCDINITVALUE) self.lcdNumberBeta.setNumDigits(self.LCDDIGITSCOUNT) self.dialBeta.valueChanged.connect(self.wyswietl_lcd_beta) self.dialSigmaR.setNotchesVisible(True) self.dialSigmaR.setMaximum(self.DIALMAX) self.dialSigmaR.setMinimum(self.DIALMIN) self.dialSigmaR.setValue(self.DIALINITVALUE) self.lcdNumberSigmaR.display(self.LCDINITVALUE) self.lcdNumberSigmaR.setNumDigits(self.LCDDIGITSCOUNT) self.dialSigmaR.valueChanged.connect(self.wyswietl_lcd_sigmar) self.pushButtonDefault.clicked.connect( self.push_button_default_clicked) self.pushButtonApply.clicked.connect(self.push_button_apply_clicked) self.InitOstatnioOtwierane() self.InitDB()
print ("开始线程:" + self.name) process_data(self.ID,self.name, self.counter) print ("退出线程:" + self.name) def process_data(id, name, counter): while not thread_flag: id += 1 if id >= 4: data = counter.get() print ("%s processing %s" % (name, data)) time.sleep(1) # 主程序 if __name__ == '__main__': app = QtWidgets.QApplication(sys.argv) t = QtCore.QElapsedTimer() t.start() splash = QtWidgets.QSplashScreen(QtGui.QPixmap("logo.jpg")) while t.elapsed() < 1000: splash.show() splash.finish(splash) MultiChannel_window = DesignerMainWindow() MultiChannel_window.show() # thread_flag = 0 # thread_list = ["draw_pictures", "collect_data", "analy_data"] # number = ["One", "Two", "Three", "Four", "Five"] # work_queue = queue.Queue(10) # threads = [] # thread_ID = 1 # for num in number:
def __init__(self): super().__init__() '''Fields''' self.simLimit = None self.simulationNo = None self.elementCount = None self.simLength = 0 self.simulation = None self.frameList = [] self.timer = QtCore.QElapsedTimer() ''' Window Properties''' self.Icon = QtGui.QIcon(str(ICON)) self.setMinimumSize(self.sizeHint()) self.resize(1600, 800) self.setWindowTitle('Vispy 3D') self.setWindowIcon(self.Icon) self.setMenuBar(DefaultMenuBar(self)) ''' Setting window layout and central widget ''' self.centralwidget = QtWidgets.QWidget() self.verticalLayout = QtWidgets.QVBoxLayout(self.centralwidget) self.verticalLayout.setAlignment(QtCore.Qt.AlignCenter) ''' Frames''' self.canvasFrame = QGroupBox("Canvas Frame") self.controlFrame = QGroupBox("Control Frame") self.renderFrame = QGroupBox() self.canvasFrameLayout = QVBoxLayout(self.canvasFrame) self.controlFrameLayout = QGridLayout(self.controlFrame) self.renderFrameLayout = QHBoxLayout() self.canvasWidget = QWidget() self.canvasWidget.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) self.canvasWidgetLayout = QHBoxLayout() ''' Rendered Video of Scene''' self.canvasHolder = QWidget() #QtWidgets.QGraphicsView()# self.canvasHolder.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) self.canvasHolderLayout = QVBoxLayout() self.canvasHolder.setLayout(self.canvasHolderLayout) ''' 'Image' Video of scene''' self.twoVideoWidget = QWidget() self.twoVideoWidget.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) self.twoVideoWidgetLayout = QVBoxLayout() self.video1Widget = QtWidgets.QGraphicsView() self.video2Widget = QtWidgets.QGraphicsView() self.twoVideoWidgetLayout.addWidget(self.video1Widget) self.twoVideoWidgetLayout.addWidget(self.video2Widget) self.twoVideoWidget.setLayout(self.twoVideoWidgetLayout) '''Simulation parameters''' self.elementCount = QLabel("Elements") self.elementCount.setMaximumSize(150,50) self.elementCountBox = QLineEdit() self.elementCountBox.setMaximumSize(350,50) self.elementCountBox.setPlaceholderText('element count') self.elementCountBox.setText('10') self.setFunctionLabel = QLabel("Set Function") self.setFunctionLabel.setMaximumSize(150,50) self.setFunctionBox = QLineEdit() self.setFunctionBox.setMaximumSize(350,50) self.setFunctionBox.setPlaceholderText("input Function in Cartesian Co-ordSinates") self.zoomLevel = QPushButton("Zoom") self.zoomLevel.setMaximumSize(150,50) self.zoomInput = QLineEdit() self.zoomLevel.clicked.connect(self.setZoom) self.zoomInput.setPlaceholderText('Adjust zoom for camera - default scale is 10.') self.zoomInput.setMaximumSize(350,50) self.simulationLengthLabel = QLabel('Simulation Length') self.simulationLengthLabel.setMaximumSize(150,50) self.simulationLengthBox = QLineEdit() self.simulationLengthBox.setMaximumSize(350,50) self.simulationLengthBox.setPlaceholderText('No. of Frames - default is 100') self.simulationLengthBox.setText('500') self.simulationsLabel = QLabel('Simulations') self.simulationsLabel.setMaximumSize(150, 50) self.simulationsBox = QLineEdit() self.simulationsBox.setMaximumSize(350,50) self.simulationsBox.setPlaceholderText('No. of simulations') ''' Render Button''' self.renderButton = QPushButton('Render') self.renderButton.clicked.connect(self.handleRender) self.renderButton.setMaximumSize(250,50) # self.renderButton.setAlignment(QtCore.Qt.AlignCenter) self.controlFrameLayout.addWidget(self.elementCount, 0, 0 ) self.controlFrameLayout.addWidget(self.elementCountBox, 0, 1) self.controlFrameLayout.addWidget(self.zoomLevel, 0, 2) self.controlFrameLayout.addWidget(self.zoomInput, 0, 3) self.controlFrameLayout.addWidget(self.setFunctionLabel,0, 4) self.controlFrameLayout.addWidget(self.setFunctionBox,0, 5) self.controlFrameLayout.addWidget(self.simulationLengthLabel, 0, 6) self.controlFrameLayout.addWidget(self.simulationLengthBox, 0, 7) self.controlFrameLayout.addWidget(self.simulationsLabel, 0, 8) self.controlFrameLayout.addWidget(self.simulationsBox, 0, 9) self.renderFrameLayout.addWidget(self.renderButton) # self.controlFrameLayout.setAlignment(self.canvasWidget, QtCore.Qt.AlignCenter) # self.canvasFrameLayout.addWidget(self.canvasWidget) self.renderFrame.setLayout(self.renderFrameLayout) self.canvasWidget.setLayout(self.canvasWidgetLayout) self.canvasFrameLayout.addWidget(self.canvasWidget) # self.canvasFrame.setLayout(self.canvasFrameLayout) self.verticalLayout.addWidget(self.canvasFrame) self.verticalLayout.addWidget(self.controlFrame) self.verticalLayout.addWidget(self.renderFrame) self.setCentralWidget(self.centralwidget)
def __init__(self, Ui_template): self.app = QtGui.QApplication([]) self.win = QtGui.QMainWindow() self.ui = Ui_template() self.ui.setupUi(self.win) # tag dialog self.dialog_box = QtGui.QDialog() self.tag_dialog = Ui_Dialog() self.tag_dialog.setupUi(self.dialog_box) # navigator dialog self.nav_dialog_box = QtGui.QDialog() self.nav_dialog = Ui_Dialog_navigation() self.nav_dialog.setupUi(self.nav_dialog_box) # Initializing the video player and output self.mediaPlayer = cv2.VideoCapture(0) # Initializing video probe self._timer = QtCore.QTimer() self._stim_timer = QtCore.QElapsedTimer() self._timer.stop() # Connecting the timer to the frame grabbing self._timer.timeout.connect(self.grabFrame) self._timer.timeout.connect(self.update_plots) self._timer.timeout.connect(self.update_trigger_plot) self._timer.timeout.connect(self.positionChanged) self._timer.timeout.connect(self.display_stimulus_data) # Connecting the toolbar actions self.ui.actionLoad_Video.triggered.connect(self.load_video) self.ui.actionLoad_data.triggered.connect(self.load_data) self.ui.play_push.setIcon(self.win.style().standardIcon( QtWidgets.QStyle.SP_MediaPlay)) self.ui.play_push.clicked.connect(self.play_all) self.ui.spinBox_offset.valueChanged.connect(self.set_offset) self.ui.fps_spin_box.valueChanged.connect(self.set_fps) self.ui.actionTag.triggered.connect(self.open_tag_dialog) # self.ui.listWidget.itemClicked.connect(self.create_checked_vector) # Tagging window btn = self.tag_dialog.button_box.button( self.tag_dialog.button_box.Apply) btn.clicked.connect(self.add_tag_to_db) self.tag_dialog.start_time.selectionChanged.connect( lambda: self.update_tag_values('start')) self.tag_dialog.end_time.selectionChanged.connect( lambda: self.update_tag_values('end')) self.tag_dialog.Delete_row.clicked.connect(self.delete_db_row) self.tag_dialog.load_csv.clicked.connect(self.load_csv_to_db) self.tag_dialog.tableWidget.cellClicked.connect(self.cellClick) # tagging class self.tag_dialog.Export.clicked.connect(self.export_to_csv) self.tag_db = Tag() # Slider interactions self.ui.positionSlider.sliderMoved.connect(self.setPosition) # Next and previous frames self.ui.prev_frame_push.clicked.connect(self.prev_frame) self.ui.next_frame_push.clicked.connect(self.next_frame) # Go to frame self.ui.spinBoxGoFrame.valueChanged.connect(self.go_to_frame) # Go to time self.ui.go_to_time_spin.valueChanged.connect(self.go_to_time) # Range self.ui.spinBox_min.valueChanged.connect(self.set_y_range) self.ui.spinBox_max.valueChanged.connect(self.set_y_range) # Menu items self.ui.actionPreprocessed_data.triggered.connect(self.load_prepros) self.ui.actionRaw_data.triggered.connect(self.load_raw) self.ui.actionICA.triggered.connect(self.load_ica) self.ui.actionRMS.triggered.connect(self.load_rms) self.ui.actionTime_of_signal.triggered.connect(self.display_time) self.ui.actionFrames.triggered.connect(self.display_frame) self.ui.actionSlice_navigator.triggered.connect(self.navigation_panel) # Video screen / Adding a scene self.scene = QtWidgets.QGraphicsScene() self.ui.videoWindow.setScene(self.scene) self.frame = QtGui.QPixmap() self.scene.addPixmap(self.frame) # initial offset between data and video self.n_of_frames = 0 # Time Span and amplitude configurations # number of seconds to display self.numOfSec = 3 # min Y max Y self.dispRange = [0, 100] # Display methood self.display_frame_bool = False # Update y axes range display # self.ui.spinBox_min.setValue(self.dispRange[0]) # self.ui.spinBox_max.setValue(self.dispRange[1]) # For Timer Stimulus LCD self.prev_stim = 1000
def __init__(self, parent=None, **kwargs): super().__init__(parent, **kwargs) self.setGeometry(350, 50, 1200, 660) self.setWindowTitle("Demo: dvg_pyqtgraph_threadsafe") # Keep track of the obtained chart refresh rate self.obtained_chart_rate_Hz = np.nan self.qet_chart = QtCore.QElapsedTimer() self.chart_rate_accumulator = 0 # Pause/unpause charts self.paused = False # GraphicsLayoutWidget self.gw = pg.GraphicsLayoutWidget() p = {"color": "#EEE", "font-size": "12pt"} self.plot_1 = self.gw.addPlot() self.plot_1.setClipToView(True) self.plot_1.showGrid(x=1, y=1) self.plot_1.setTitle("HistoryChartCurve") self.plot_1.setLabel("bottom", text="history (sec)", **p) self.plot_1.setLabel("left", text="amplitude", **p) self.plot_1.setRange( xRange=[-1.04 * CHART_HISTORY_TIME, CHART_HISTORY_TIME * 0.04], yRange=[-1.1, 1.1], disableAutoRange=True, ) self.plot_2 = self.gw.addPlot() # self.plot_2.setClipToView(True) # Note: Do not enable clip for a Lissajous. Clip only works well on uniformly monotic x-data. self.plot_2.showGrid(x=1, y=1) self.plot_2.setTitle("BufferedPlotCurve: Lissajous") self.plot_2.setLabel("bottom", text="x", **p) self.plot_2.setLabel("left", text="y", **p) self.plot_2.setRange( xRange=[-1.1, 1.1], yRange=[-1.1, 1.1], disableAutoRange=True, ) capacity = round(CHART_HISTORY_TIME * Fs) self.tscurve_1 = HistoryChartCurve( capacity=capacity, linked_curve=self.plot_1.plot(pen=pg.mkPen(color=[255, 30, 180], width=3), name="wave 1"), ) self.tscurve_2 = HistoryChartCurve( capacity=capacity, linked_curve=self.plot_1.plot(pen=pg.mkPen(color=[0, 255, 255], width=3), name="wave 2"), ) self.tscurve_3 = BufferedPlotCurve( capacity=capacity, linked_curve=self.plot_2.plot(pen=pg.mkPen(color=[255, 255, 90], width=3), name="Lissajous"), ) self.tscurves = [ self.tscurve_1, self.tscurve_2, self.tscurve_3, ] # Extra marker to indicate tracking position of Lissajous curve self.lissajous_marker = self.plot_2.plot( pen=None, symbol="o", symbolPen=None, symbolBrush=pg.mkBrush([255, 30, 180]), symbolSize=16, ) # 'Obtained rates' self.qlbl_DAQ_rate = QtWid.QLabel("") self.qlbl_DAQ_rate.setAlignment(QtCore.Qt.AlignRight) self.qlbl_DAQ_rate.setMinimumWidth(50) self.qlbl_chart_rate = QtWid.QLabel("") self.qlbl_chart_rate.setAlignment(QtCore.Qt.AlignRight) self.qlbl_num_points = QtWid.QLabel("") self.qlbl_num_points.setAlignment(QtCore.Qt.AlignRight) # fmt: off grid_rates = QtWid.QGridLayout() grid_rates.addWidget(QtWid.QLabel("DAQ:"), 0, 0) grid_rates.addWidget(self.qlbl_DAQ_rate, 0, 1) grid_rates.addWidget(QtWid.QLabel("Hz"), 0, 2) grid_rates.addWidget(QtWid.QLabel("chart:"), 1, 0) grid_rates.addWidget(self.qlbl_chart_rate, 1, 1) grid_rates.addWidget(QtWid.QLabel("Hz"), 1, 2) grid_rates.addWidget(QtWid.QLabel("drawn:"), 2, 0) grid_rates.addWidget(self.qlbl_num_points, 2, 1) grid_rates.addWidget(QtWid.QLabel("pnts"), 2, 2) grid_rates.setAlignment(QtCore.Qt.AlignTop) # fmt: on # 'Legend' legend = LegendSelect(linked_curves=self.tscurves) qgrp_legend = QtWid.QGroupBox("LegendSelect") qgrp_legend.setLayout(legend.grid) # Update `number of points drawn` at each click `show/hide curve` for chkb in legend.chkbs: chkb.clicked.connect(self.update_num_points_drawn) # `PlotManager` self.qpbt_pause_chart = QtWid.QPushButton("Pause", checkable=True) self.qpbt_pause_chart.clicked.connect(self.process_qpbt_pause_chart) self.plot_manager = PlotManager(parent=self) self.plot_manager.grid.addWidget(self.qpbt_pause_chart, 0, 0, 1, 2) self.plot_manager.grid.addItem(QtWid.QSpacerItem(0, 10), 1, 0) self.plot_manager.add_autorange_buttons( linked_plots=[self.plot_1, self.plot_2]) self.plot_manager.add_preset_buttons( linked_plots=[self.plot_1], linked_curves=[self.tscurve_1, self.tscurve_2], presets=[ { "button_label": "0.100", "x_axis_label": "history (msec)", "x_axis_divisor": 1e-3, "x_axis_range": (-101, 0), }, { "button_label": "0:05", "x_axis_label": "history (sec)", "x_axis_divisor": 1, "x_axis_range": (-5.05, 0), }, { "button_label": "0:10", "x_axis_label": "history (sec)", "x_axis_divisor": 1, "x_axis_range": (-10.1, 0), }, ], ) self.plot_manager.add_clear_button(linked_curves=self.tscurves) self.plot_manager.perform_preset(1) qgrp_plotmgr = QtWid.QGroupBox("PlotManager") qgrp_plotmgr.setLayout(self.plot_manager.grid) # Round up right panel vbox = QtWid.QVBoxLayout() vbox.addLayout(grid_rates) vbox.addWidget(qgrp_legend) vbox.addWidget(qgrp_plotmgr, stretch=0) vbox.addStretch() # Round up frame hbox = QtWid.QHBoxLayout() hbox.addWidget(self.gw, 1) hbox.addLayout(vbox, 0) # ------------------------- # Round up full window # ------------------------- vbox = QtWid.QVBoxLayout(self) vbox.addLayout(hbox, stretch=1)
dictionary_teams[name[:-1]] = Team(folder, name[:-1].replace('_', ' ')) return dictionary_teams if __name__ == "__main__": match_state = 0 ski, tchoukball, gym = 0, 1, 2 app = QApplication(sys.argv) # Init team and match files folder_name = "team_match" dict_teams = init_team_files(folder_name) # Init and start timer start_timer = QtCore.QElapsedTimer() start_timer.start() # Create display window ui_beamer = DisplayWindow(start_timer, folder_name) ui_beamer.main() # Create command window ui_commande = CommandWindow(start_timer, ui_beamer, dict_teams, folder_name, match_state) ui_commande.main() sys.exit(app.exec_())