-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtext_display.py
More file actions
31 lines (24 loc) · 1 KB
/
Copy pathtext_display.py
File metadata and controls
31 lines (24 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from PySide6.QtCore import Qt
from PySide6.QtGui import QMouseEvent
from PySide6.QtWidgets import QApplication, QTextEdit
class TextDisplay(QTextEdit):
def __init__(self):
super().__init__()
def mouseMoveEvent(self, e: QMouseEvent):
self.anchor = self.anchorAt(e.position().toPoint())
if self.anchor:
QApplication.setOverrideCursor(Qt.CursorShape.PointingHandCursor)
else:
QApplication.setOverrideCursor(Qt.CursorShape.ArrowCursor)
def mousePressEvent(self, e: QMouseEvent):
self.anchor = self.anchorAt(e.position().toPoint())
if self.anchor:
print(f"Anchor: {self.anchor}")
# if self.anchor:
# QApplication.setOverrideCursor(Qt.CursorShape.PointingHandCursor)
def mouseReleaseEvent(self, e: QMouseEvent):
# if self.anchor:
# QDesktopServices.openUrl(QUrl(self.anchor))
# QApplication.setOverrideCursor(Qt.CursorShape.ArrowCursor)
# self.anchor = None
pass