EventTest
## -*- coding: utf-8 -*-
import sys
from PySide import QtCore, QtGui
from PySide.QtUiTools import QUiLoader
import remitools.lib.qt as remiQt
class eventtest(QtGui.QDialog):
"""
EventTest
"""
uiFile = "e:/Bitbucket/scripttestdev/Qt/eventtest.ui"
def __init__(self):
super(eventtest, self).__init__(remiQt.getMayaWindow())
self.ui = remiQt.loadUi(self.uiFile)
layout = QtGui.QVBoxLayout()
layout.addWidget(self.ui)
self.setLayout(layout)
self.resize(350,300)
def mousePressEvent(self,event):
self.ui.boxX.setText(str(event.x()))
self.ui.boxY.setText(str(event.y()))
def paintEvent(self,event):
#直線を描画
painter = QtGui.QPainter(self)
painter.drawLine(QtCore.QLine(40,120,300,120))
painter.drawLine(QtCore.QLine(40,190,300,190))
painter.drawLine(QtCore.QLine(40,120,40,190))
painter.drawLine(QtCore.QLine(300,120,300,190))
#文字を描画
painter.setFont(QtGui.QFont("Arial",20))
painter.drawText(QtCore.QPoint(50,150),u"画面をクリックすると、")
painter.drawText(QtCore.QPoint(50,180),u"座標を表示するよ")
if __name__ == "__main__":
app = eventtest()
app.show()