How to use waitText method in fMBT

Best Python code snippet using fMBT_python

GraphicsScene.py

Source:GraphicsScene.py Github

copy

Full Screen

1from PyQt4 import QtGui, QtCore2import sys34#defines the size for a square in the field5SIZE = 506#defines the size of the circles in the field7CIRCLESIZE = 4589class GraphicsScene(QtGui.QGraphicsScene):10 def __init__(self, nrRows, nrCols, color, win_parent = None):11 QtGui.QGraphicsScene.__init__(self, win_parent)12 13 self.nrRows = nrRows14 self.nrCols = nrCols15 #contains the column number of the column where the mouse is at16 self.currentHoverIndex = -117 18 self.setupDefaultBoard(nrRows, nrCols)19 self.setupTempBlock(nrRows, nrCols, color)20 21 self.waitText = QtGui.QGraphicsTextItem()22 self.waitText = self.addText("...Please wait...")23 self.waitText.setZValue(100)24 self.freezeText = QtGui.QGraphicsTextItem()25 self.freezeText = self.addText("...Game frozen...")26 self.freezeText.setZValue(100)27 font = QtGui.QFont()28 font.setBold(True)29 font.setFamily("Comic Sans MS")30 font.setPointSize(30)31 self.waitText.setFont(font)32 self.freezeText.setFont(font)33 self.waitText.setDefaultTextColor(QtGui.QColor(0,0,255))34 self.freezeText.setDefaultTextColor(QtGui.QColor(0,0,255))35 sceneSize = self.sceneRect()36 midx = (sceneSize.width() / 2) - (self.waitText.boundingRect().width() / 2)37 midy = (sceneSize.height() / 2) - (self.waitText.boundingRect().height() / 2)38 self.waitText.setPos(midx, midy)39 midx = (sceneSize.width() / 2) - (self.freezeText.boundingRect().width() / 2)40 midy = (sceneSize.height() / 2) - (self.freezeText.boundingRect().height() / 2)41 self.freezeText.setPos(midx, midy)42 self.waitText.hide()43 self.freezeText.hide()44 45 self.rejectClicks = False4647 48 def block(self, freeze):49 self.setForegroundBrush(QtGui.QBrush(QtGui.QColor(50, 50, 50, 180)))50 if(freeze):51 self.freezeText.show()52 else:53 self.waitText.show()54 self.rejectClicks = True55 56 def unblock(self, freeze):57 if(self.freezeText.isVisible() and not freeze):58 self.waitText.hide()59 return60 self.setForegroundBrush(QtGui.QBrush(QtCore.Qt.NoBrush))61 if(freeze):62 self.freezeText.hide()63 else:64 self.waitText.hide()65 self.rejectClicks = False66 67 def setupDefaultBoard(self, nrRows, nrCols):68 self.gameBoard = [[QtGui.QGraphicsRectItem for i in xrange(nrRows)] for j in xrange(nrCols)]69 for i in range(nrCols):70 for j in range(nrRows):71 rectItem = QtGui.QGraphicsRectItem(i*SIZE, j*SIZE, SIZE, SIZE)72 self.addItem(rectItem)73 self.gameBoard[i][j] = rectItem74 75 self.setSceneRect(-10, -10, nrCols * SIZE +20, nrRows * SIZE + 20)76 77 def setupTempBlock(self, nrRows, nrCols, color):78 #contains the item that shows where the next block will fall:79 80 self.tempItem = QtGui.QGraphicsEllipseItem(0 + (SIZE - CIRCLESIZE)/2, nrRows-1 + (SIZE - CIRCLESIZE)/2, CIRCLESIZE, CIRCLESIZE)81 82 self.radialGrad = QtGui.QRadialGradient(0 + (CIRCLESIZE/2) + (SIZE - CIRCLESIZE)/2, nrRows-1 + (CIRCLESIZE/2) + (SIZE - CIRCLESIZE)/2, CIRCLESIZE/2)83 self.radialGrad.setColorAt(0, color)84 #radialGrad.setColorAt(0.45, QtGui.QColor(255,255,255))85 self.radialGrad.setColorAt(1, QtGui.QColor(255,255,255))86 brush = QtGui.QBrush(self.radialGrad)87 88 pen = QtGui.QPen(QtCore.Qt.NoPen)89 90 self.tempItem.setPen(pen)91 self.tempItem.setBrush(brush)92 self.tempItem.setZValue(2)9394 self.addItem(self.tempItem)95 self.tempItem.hide()96 97 def makeMove(self, xpos, ypos, color):98 self.currentHoverIndex = -199 self.tempItem.hide()100 101 rectItem = self.gameBoard[xpos][ypos]102 x = rectItem.rect().x()103 y = rectItem.rect().y()104 105 xpos = x + (SIZE - CIRCLESIZE)/2106 ypos = y + (SIZE - CIRCLESIZE)/2107 108 circleItem = QtGui.QGraphicsEllipseItem(xpos, ypos, CIRCLESIZE, CIRCLESIZE)109 110 xpos = x + (CIRCLESIZE/2) + (SIZE - CIRCLESIZE)/2111 ypos = y + (CIRCLESIZE/2) + (SIZE - CIRCLESIZE)/2112 113 radialGrad = QtGui.QRadialGradient(xpos, ypos, CIRCLESIZE/2)114 radialGrad.setColorAt(0, color)115 radialGrad.setColorAt(0.45, color)116 radialGrad.setColorAt(1, QtGui.QColor(255,255,255))117 brush = QtGui.QBrush(radialGrad)118 119 pen = QtGui.QPen(QtCore.Qt.NoPen)120 121 circleItem.setPen(pen)122 circleItem.setBrush(brush)123 circleItem.setZValue(3)124 125 self.addItem(circleItem)126 127 def makeDummyMove(self, columnIndex, rowIndex, color):128 self.tempItem.hide()129130 rectItem = self.gameBoard[columnIndex][rowIndex]131 x = rectItem.rect().x()132 y = rectItem.rect().y()133 134 xpos = x + (SIZE - CIRCLESIZE)/2135 ypos = y + (SIZE - CIRCLESIZE)/2136 137 self.tempItem.setRect(xpos, ypos, CIRCLESIZE, CIRCLESIZE)138 139 self.radialGrad = QtGui.QRadialGradient(x + (CIRCLESIZE/2) + (SIZE - CIRCLESIZE)/2, y + (CIRCLESIZE/2) + (SIZE - CIRCLESIZE)/2, CIRCLESIZE/2)140 self.radialGrad.setColorAt(0, color)141 #radialGrad.setColorAt(0.45, QtGui.QColor(255,255,255))142 self.radialGrad.setColorAt(1, QtGui.QColor(255,255,255))143 brush = QtGui.QBrush(self.radialGrad)144 145 pen = QtGui.QPen(QtCore.Qt.NoPen)146 147 self.tempItem.setPen(pen)148 self.tempItem.setBrush(brush)149 self.tempItem.setZValue(2)150 151 self.tempItem.show()152 153 def mousePressEvent(self, event):154 self.tempItem.hide()155 # Only accept a move when the gameboard is enabled156 if(not self.rejectClicks):157 item = self.itemAt(event.scenePos())158 for i in range(self.nrCols):159 for j in range(self.nrRows):160 if(self.gameBoard[i][j] == item):161 self.emit(QtCore.SIGNAL("playerClicked(int)"), i)162 163 def mouseDoubleClickEvent(self, event):164 self.tempItem.hide()165 #this enables the user to click rapidly166 if(not self.rejectClicks):167 item = self.itemAt(event.scenePos())168 for i in range(self.nrCols):169 for j in range(self.nrRows):170 if(self.gameBoard[i][j] == item):171 self.emit(QtCore.SIGNAL("playerClicked(int)"), i)172 173 def mouseMoveEvent(self, event):174 item = self.itemAt(event.scenePos())175 if(not self.rejectClicks):176 self.tempItem.show()177 for i in range(self.nrCols):178 for j in range(self.nrRows):179 if(self.gameBoard[i][j] == item):180 if(i != self.currentHoverIndex):181 self.currentHoverIndex = i182 self.emit(QtCore.SIGNAL("mouseHoverColumn(int)"), i) ...

Full Screen

Full Screen

1-BaseDesign.py

Source:1-BaseDesign.py Github

copy

Full Screen

1from __future__ import absolute_import, division2import numpy as np3from definition import *4# Store info about the experiment session5Date=data.getDateStr()6expName = 'PsychopyTutorial_1st'7expInfo = {8 'Title': expName, 9 'Date' : Date,10 'SubId': '00',11 'Session': '00'12 }13dlg = gui.DlgFromDict(dictionary=expInfo, sortKeys=False, title=expName)14if dlg.OK == False:15 core.quit() 16# Setup the Window and Keyboard17win = set_window()18defaultKeyboard = keyboard.Keyboard()19# Initialize "Wait" Components20WaitText = set_text(win, 'WaitText')21WaitSignal = keyboard.Keyboard()22WaitComponents=[WaitText, WaitSignal]23# Initialize "Trial" Components24Dot = set_circle(win, 'Dot')25Stim = set_image(win, 'Stim')26Signal = keyboard.Keyboard()27Response = keyboard.Keyboard()28TrialComponents=[Dot, Stim, Signal, Response]29# Create some handy timers30WaitClock = core.Clock()31TrialClock = core.Clock()32routineTimer = core.CountdownTimer() 33frameTolerance = 0.001 34##############################################35#------------------- WAIT -------------------#36##############################################37# 1. Set "Wait" Timer38WaitClock.reset(-win.getFutureFlipTime(clock="now"))39# 2. Initialize "Wait" Components40initComponents(WaitComponents)41# 3. Start "Wait" Routine42while True:43 # set this routine 44 WaitRoutine = Routine(win, WaitClock)45 46 # components update47 WaitRoutine.visual(WaitText, 1000) 48 signal = WaitRoutine.response(WaitSignal, 1000, ['s']) 49 if len(signal):50 break51 52 if defaultKeyboard.getKeys(keyList=["escape"]):53 core.quit()54 55 win.flip()56# 4. Ending "Wait" Routine57endRoutine(WaitComponents)58###############################################59#------------------- TRIAL -------------------#60###############################################61# 1. Set Trial timer62TrialClock.reset(-win.getFutureFlipTime(clock="now"))63for i in range(1, 15):64 65 # 2. Initialize Components66 initComponents(TrialComponents)67 68 # 3. Set Trial Routine timer69 setTime=270 routineTimer.reset()71 routineTimer.add(setTime)72 73 # 4. Set image74 img = './stim/%i.jpg'%(i)75 Stim.setImage(img)76 # 5. Start "Trial" Routine77 while routineTimer.getTime() > frameTolerance:78 # set this flip79 TrialRoutine = Routine(win, TrialClock)80 # components update81 TrialRoutine.visual(Stim, 1) 82 TrialRoutine.visual(Dot, setTime) 83 signal = TrialRoutine.response(Signal, setTime, 's') 84 if len(signal):85 Signal.rt = signal[-1].rt86 break87 response = TrialRoutine.response(Response, setTime, 'r') 88 if len(response):89 Response.rt = response[-1].rt90 # set quit key 91 if defaultKeyboard.getKeys(keyList=["escape"]):92 core.quit()93 win.flip()94 95 print(i, Stim.tStart, Signal.rt, Response.rt)96 97 # 6. Ending Routine "Trial"98 endRoutine(TrialComponents)99 100 101win.flip()102logging.flush()103win.close()...

Full Screen

Full Screen

wait.py

Source:wait.py Github

copy

Full Screen

1import os2from PyQt5 import QtCore, QtWidgets3import main4'''5 Wait Operation and its properties6'''7class waitWindow(QtWidgets.QMainWindow):8 def __init__(self):9 super(waitWindow, self).__init__()10 sshFile = os.path.join("style", "style.qss")11 with open(sshFile, "r") as fh:12 self.setStyleSheet(fh.read())13 self.initUI()14 def initUI(self):15 self.setObjectName("wait")16 self.resize(650, 250)17 self.setWindowTitle("Properties for wait")18 self.waitlabel = QtWidgets.QLabel(self)19 self.waitlabel.setGeometry(QtCore.QRect(100, 90, 151, 31))20 self.waitlabel.setObjectName("label")21 self.waitlabel.setText("Enter the wait time in sec ")22 self.waittextEdit = QtWidgets.QTextEdit(self)23 self.waittextEdit.setGeometry(QtCore.QRect(260, 90, 301, 30))24 self.waittextEdit.setObjectName("textEdit")25 self.wait_OK_Button = QtWidgets.QPushButton(self)26 self.wait_OK_Button.setGeometry(QtCore.QRect(260, 180, 75, 31))27 self.wait_OK_Button.setObjectName("wait_OK_Button")28 self.wait_OK_Button.clicked.connect(self.writeScript)29 self.wait_OK_Button.setText("OK")30 self.wait_Close_Button = QtWidgets.QPushButton(self)31 self.wait_Close_Button.setGeometry(QtCore.QRect(360, 180, 75, 31))32 self.wait_Close_Button.setObjectName("wait_Close_Button")33 self.wait_Close_Button.clicked.connect(self.close_properties)34 self.wait_Close_Button.setText("CANCEL")35 self.show()36 '''37 Script Generation and write to File38 '''39 def writeScript(self):40 data = self.waittextEdit.toPlainText()41 script = os.path.join("resource", "script.tagui")42 with open(script, "a") as f:43 f.write("\n")44 f.write("wait " + str(data))45 self.close_properties()46 main.ProcessWindow.refresh(self)47 def close_properties(self):...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fMBT automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful