프로그램
[파이썬] 문제 : PyQt5 마우스 더블클릭 이벤트
오디세이99
2022. 12. 10. 14:08
728x90
반응형
import sys
from PyQt5.QtWidgets import QApplication, QWidget, QLabel
from PyQt5 import QtCore, QtGui
class MyApp(QWidget):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
x = 0
y = 0
self.text = 'x: {0}, y: {1}'.format(x, y)
self.label = QLabel(self.text, self)
self.label.setFont(QtGui.QFont("굴림",16)) #폰트,크기 조절
self.label.setStyleSheet("Color : red") #글자색 변환
self.label.move(20, 20)
self.setMouseTracking(True)
self.setWindowTitle('Mouse doubleClick Event')
self.setGeometry(300, 300, 300, 200)
self.show()
def mouseDoubleClickEvent(self, e): # 마우스 더블크릭 이벤트
x = e.x()
y = e.y()
text = 'x: {0}, y: {1}'.format(x, y)
self.label.setText(text)
self.label.adjustSize()
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = MyApp()
sys.exit(app.exec_())
728x90
반응형