개정판 5a2af51c
issue #1221: 데이타 시트 출력
Change-Id: I8fad48712d1bdd485d54205bd21be9e0bf1533dd
DTI_PID/DTI_PID/EqpDatasheetExportDialog.py | ||
---|---|---|
6 | 6 |
from PyQt5.QtCore import * |
7 | 7 |
from PyQt5.QtGui import * |
8 | 8 |
from PyQt5.QtWidgets import * |
9 |
from openpyxl import * |
|
10 |
from openpyxl.styles import * |
|
9 | 11 |
|
10 | 12 |
from AppDocData import AppDocData, MessageType |
11 | 13 |
|
12 | 14 |
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)) + '\\UI') |
13 | 15 |
import EqpDatasheetExport_UI |
14 | 16 |
|
17 |
|
|
15 | 18 |
class QEqpDatasheetExportDialog(QDialog): |
16 | 19 |
""" This Equipment Datasheet Export dialog class """ |
17 | 20 |
|
... | ... | |
46 | 49 |
QDialog.accept(self) |
47 | 50 |
except Exception as ex: |
48 | 51 |
from App import App |
49 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
52 |
message = 'error occurred({}) in {}:{}'.format(repr(ex), sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
53 |
sys.exc_info()[-1].tb_lineno) |
|
50 | 54 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
51 | 55 |
|
52 | 56 |
def export_equipment_data_sheet(self, equipments, _type): |
53 | 57 |
""" export given equipments to data sheet """ |
54 | 58 |
|
55 |
pass |
|
59 |
import re |
|
60 |
|
|
61 |
try: |
|
62 |
app_doc_data = AppDocData.instance() |
|
63 |
path = app_doc_data.project.get_data_sheet_path() |
|
64 |
data_sheet = os.path.join(path, f"{_type}.xlsx") |
|
65 |
if os.path.isfile(data_sheet): |
|
66 |
reg_expr = re.compile('^\\$\\(.+\\)$') |
|
67 |
book = load_workbook(data_sheet) |
|
68 |
for equipment in equipments: |
|
69 |
count = len(book.sheetnames) |
|
70 |
sheet = book.copy_worksheet(book.worksheets[0]) |
|
71 |
sheet.title = f"{_type}({count})" |
|
72 |
for row in sheet.rows: |
|
73 |
for col in range(sheet.max_column): |
|
74 |
if row[col].value and reg_expr.match(str(row[col].value)): |
|
75 |
name = str(row[col].value)[2:-1] |
|
76 |
matches = [attr for attr in equipment if attr[0] == name] |
|
77 |
if matches: |
|
78 |
row[col].value = matches[0][1] |
|
79 |
|
|
80 |
options = QFileDialog.Options() |
|
81 |
options |= QFileDialog.DontUseNativeDialog |
|
82 |
file_name = QFileDialog.getSaveFileName(self, f"{_type} xlsx file", app_doc_data.project.path, |
|
83 |
"xlsx files(*.xlsx)", options=options) |
|
84 |
if file_name[0]: |
|
85 |
file_name, ext = os.path.splitext(file_name[0]) |
|
86 |
book.save(file_name + ext if ext.upper() == '.XLSX' else file_name + '.xlsx') |
|
87 |
|
|
88 |
book.close() |
|
89 |
|
|
90 |
except Exception as ex: |
|
91 |
from App import App |
|
92 |
message = 'error occurred({}) in {}:{}'.format(repr(ex), sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
93 |
sys.exc_info()[-1].tb_lineno) |
|
94 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
DTI_PID/DTI_PID/MainWindow_UI.py | ||
---|---|---|
21 | 21 |
font.setWeight(75) |
22 | 22 |
MainWindow.setFont(font) |
23 | 23 |
icon = QtGui.QIcon() |
24 |
icon.addPixmap(QtGui.QPixmap(":/images/qrc/checkbox.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
|
24 |
icon.addPixmap(QtGui.QPixmap(":/newPrefix/ID2.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
|
25 | 25 |
MainWindow.setWindowIcon(icon) |
26 | 26 |
self.centralwidget = QtWidgets.QWidget(MainWindow) |
27 | 27 |
self.centralwidget.setObjectName("centralwidget") |
DTI_PID/DTI_PID/UI/MainWindow.ui | ||
---|---|---|
28 | 28 |
</property> |
29 | 29 |
<property name="windowIcon"> |
30 | 30 |
<iconset resource="../res/MainWindow.qrc"> |
31 |
<normaloff>:/images/qrc/checkbox.png</normaloff>:/images/qrc/checkbox.png</iconset>
|
|
31 |
<normaloff>:/newPrefix/ID2.png</normaloff>:/newPrefix/ID2.png</iconset>
|
|
32 | 32 |
</property> |
33 | 33 |
<widget class="QWidget" name="centralwidget"> |
34 | 34 |
<layout class="QGridLayout" name="gridLayout"> |
내보내기 Unified diff