-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
29 lines (24 loc) · 923 Bytes
/
test.py
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
from PyQt5 import QtWidgets
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QTextCharFormat
class Widget(QtWidgets.QWidget):
def __init__(self, parent = None):
super().__init__(parent)
self.text_box = QtWidgets.QTextEdit(self)
layout = QtWidgets.QVBoxLayout(self)
layout.addWidget(self.text_box)
def keyPressEvent(self, event):
if event.modifiers() == Qt.ShiftModifier and event.key() == Qt.Key_F6:
cursor = self.text_box.textCursor()
if format.verticalAlignment() == QTextCharFormat.AlignSubScript:
vert = QTextCharFormat.AlignNormal
else:
vert = QTextCharFormat.AlignSubScript
print(vert)
format.setVerticalAlignment(vert)
cursor.setCharFormat(format)
if __name__ == "__main__":
app = QtWidgets.QApplication([])
w = Widget()
w.show()
app.exec()