-
Notifications
You must be signed in to change notification settings - Fork 4
/
test.py
33 lines (26 loc) · 1.01 KB
/
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
30
31
32
33
from PyQt5.QtGui import QColor
from PyQt5.QtWidgets import QMainWindow, QApplication, QHBoxLayout, QWidget, QTextEdit
from pyqt_color_picker import ColorPickerWidget
class Window(QMainWindow):
def __init__(self):
super().__init__()
self.__initUi()
def __initUi(self):
self.__te = QTextEdit()
self.__colorPicker = ColorPickerWidget(orientation='vertical')
self.__colorPicker.colorChanged.connect(self.colorChanged) # when color has changed, call the colorChanged function
# self.__colorPicker.setCurrentColor('yellow')
lay = QHBoxLayout()
lay.addWidget(self.__te)
lay.addWidget(self.__colorPicker)
mainWidget = QWidget()
mainWidget.setLayout(lay)
self.setCentralWidget(mainWidget)
def colorChanged(self, color):
self.__te.setStyleSheet(f'QTextEdit {{ color: {color.name()} }}')
if __name__ == "__main__":
import sys
app = QApplication(sys.argv)
ex = Window()
ex.show()
sys.exit(app.exec_())