개정판 072254e4
issue #1048: 화면/메뉴/툴바 개발 - 기기 형상을 툴팁으로 보여줌(원본대비 3배로 키움)
Change-Id: I5380554e9b13f91681983e4303751830a5eb947b
HYTOS/HYTOS/SymbolTreeWidget.py | ||
---|---|---|
77 | 77 |
humkyung 2018.07.30 sort child items |
78 | 78 |
''' |
79 | 79 |
def loadSymbolInfo(self): |
80 |
from PyQt5.QtSvg import QSvgRenderer |
|
81 |
|
|
80 | 82 |
try: |
81 | 83 |
symbolCategoryList = AppDocData.instance().getSymbolCategoryList() |
82 | 84 |
for symbolCategory in symbolCategoryList: |
... | ... | |
92 | 94 |
|
93 | 95 |
symbolList = AppDocData.instance().getSymbolListByUID(symbolType[0]) |
94 | 96 |
for symbol in symbolList: |
95 |
#symbolItem = QTreeWidgetItem(category, [symbol.getName()]) |
|
96 | 97 |
symbolItem = QTreeWidgetItem(category, [symbol.sName, symbol.uid]) |
97 | 98 |
symbolItem.setData(0, self.TREE_DATA_ROLE, symbol) |
98 | 99 |
svgPath = symbol.getSvgFileFullPath() |
... | ... | |
100 | 101 |
symbolItem.setIcon(0, icon) |
101 | 102 |
symbolItem.svgFilePath = svgPath # save svg file path |
102 | 103 |
|
104 |
# show symbol tree item tooltip with image(size*3) |
|
105 |
renderer = QSvgRenderer(svgPath) |
|
106 |
image = QImage(renderer.defaultSize()*3, QImage.Format_ARGB32) |
|
107 |
painter = QPainter(image) |
|
108 |
with painter: |
|
109 |
renderer.render(painter) |
|
110 |
buffer = QBuffer() |
|
111 |
buffer.open(QIODevice.WriteOnly) |
|
112 |
image.save(buffer, "PNG", quality=100) |
|
113 |
pixmap = bytes(buffer.data().toBase64()).decode() |
|
114 |
html = '<img src="data:image/png;base64,{}>"'.format(pixmap) |
|
115 |
symbolItem.setToolTip(0, html) |
|
116 |
|
|
103 | 117 |
parent.sortChildren(0, Qt.AscendingOrder) |
104 | 118 |
except Exception as ex: |
105 | 119 |
from App import App |
내보내기 Unified diff