本文整理汇总了Python中circle.Circle.x方法的典型用法代码示例。如果您正苦于以下问题:Python Circle.x方法的具体用法?Python Circle.x怎么用?Python Circle.x使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类circle.Circle
的用法示例。
在下文中一共展示了Circle.x方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ClickRecorder
# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import x [as 别名]
class ClickRecorder(QtGui.QWidget):
def requestFileName(self):
if len(sys.argv) < 2:
sys.exit(0)
else:
self.fileName = sys.argv[1]
# read content of test setup file and calculate random
def readTestSetup(self):
# read input
with open(self.fileName) as f:
content = f.read()
if not content:
# print "File is empty"
sys.exit(0)
userLines = content.split()
# split description and comma-separated values, take values
# and convert to int
self.userId = userLines[0].split(":")[1]
widths = map(int, userLines[1].split(":")[1].split(","))
distances = map(int, userLines[2].split(":")[1].split(","))
self.filename = "user" + self.userId
# calculate possible combinations of distances and widths
self.distWidthCombis = list(itertools.product(distances, widths))
# randomize order of combinations of distance and width
random.shuffle(self.distWidthCombis)
def __init__(self):
super(ClickRecorder, self).__init__()
self.requestFileName()
self.readTestSetup()
self.initUI()
self.setupStartRect()
self.setupTrial()
self.setupLogging()
def setupStartRect(self):
self.marginTop = self.res.height() / 3
self.marginLeft = 100
self.startCircle = Circle(50, self.marginLeft, self.marginTop)
def setupCircle(self):
width = self.distWidthCombis[self.trialsCount][1]
distance = self.distWidthCombis[self.trialsCount][0]
marginLeft = self.marginLeft + self.startCircle.diameter + distance
self.circle = Circle(width, marginLeft - width / 2, self.marginTop)
self.update()
def setupTrial(self):
self.circle = None
self.errors = 0
self.maxTrialsRepetition = 4
self.maxTrialsCount = 16
self.experimentOver = False
self.trialsRepetition = 0
self.trialsCount = 0
def initUI(self):
self.setWindowTitle("A Study about Fitts's Law")
self.setFocusPolicy(QtCore.Qt.StrongFocus)
self.showFullScreen()
self.show()
self.res = QtGui.QDesktopWidget().screenGeometry()
def paintEvent(self, event):
qp = QtGui.QPainter()
qp.begin(self)
qp.setRenderHint(qp.Antialiasing)
qp.setBrush(QtGui.QColor(255, 255, 255))
qp.drawRect(event.rect())
self.drawState(event, qp)
if self.experimentOver is True:
pass
else:
self.drawCircles(event, qp)
qp.end()
# handle mouse press event
def mousePressEvent(self, event):
# check only left buton click
if event.button() == QtCore.Qt.LeftButton:
# start circle is hit and there's no target circle right now
if self.startCircle.isClicked(event.pos()) and self.circle is None:
self.setupCircle()
self.initPosX = event.pos().x()
self.initPosY = event.pos().y()
self.targetPosX = self.circle.x()
self.targetPosY = self.circle.y()
self.start = int(round(time.time() * 1000))
# there's a target circle
elif self.circle is not None:
self.clickPosX = event.pos().x()
self.clickPosY = event.pos().y()
#.........这里部分代码省略.........