개정판 3ef1448f
issue #49: 엑셀 불러오기 기능 완료
Change-Id: Iac3037d286c9626278e59a0329e054fb72e1437c
DTI_PID/DTI_PID/CodeTableDialog.py | ||
---|---|---|
12 | 12 |
from openpyxl.styles import * |
13 | 13 |
import CodeTable_UI |
14 | 14 |
|
15 |
|
|
16 | 15 |
class QCodeTableDialog(QDialog): |
17 | 16 |
""" This code table dialog class """ |
18 | 17 |
|
... | ... | |
64 | 63 |
tableDatas = docData.getCodeTable(tableName) |
65 | 64 |
|
66 | 65 |
if tableName == "NominalDiameter": |
67 |
self.insertTableWidgetNominalPipeSizeRow(tableDatas)
|
|
66 |
self.fill_nominal_pipe_sizes(tableDatas)
|
|
68 | 67 |
|
69 | 68 |
table.cellChanged.connect(self.cellValueChanged) |
70 | 69 |
self.checkRowAndAddRow(tableName, table) |
... | ... | |
73 | 72 |
table.setHorizontalHeaderLabels(['UID', 'Code', 'Desc.', 'Allowables']) |
74 | 73 |
table.hideColumn(0) |
75 | 74 |
|
76 |
self.insertTableWidgetCommonRow(table, tableDatas)
|
|
75 |
self.fill_codes(table, tableDatas)
|
|
77 | 76 |
|
78 | 77 |
table.horizontalHeaderItem(1).setSizeHint(QSize(30, 30)) |
79 | 78 |
table.cellChanged.connect(self.cellValueChanged) |
... | ... | |
89 | 88 |
@date 2018.07.10 |
90 | 89 |
''' |
91 | 90 |
|
92 |
def insertTableWidgetNominalPipeSizeRow(self, pipeSizes):
|
|
91 |
def fill_nominal_pipe_sizes(self, pipeSizes):
|
|
93 | 92 |
try: |
94 | 93 |
self.ui.tableWidgetNominalDiameter.setColumnCount(7) |
95 | 94 |
self.ui.tableWidgetNominalDiameter.setHorizontalHeaderLabels( |
96 |
['Code', 'Metric', 'Inch', 'InchStr', 'Allowables', 'MetricStr', 'Allowables'])
|
|
95 |
['Code', 'Metric', 'Inch', 'InchStr', 'Inch Allowables', 'MetricStr', 'Metric Allowables'])
|
|
97 | 96 |
self.ui.tableWidgetNominalDiameter.setRowCount(len(pipeSizes)) |
98 | 97 |
row = 0 |
99 | 98 |
for pipeSize in pipeSizes: |
... | ... | |
128 | 127 |
@date 2018.07.10 |
129 | 128 |
''' |
130 | 129 |
|
131 |
def insertTableWidgetCommonRow(self, table, tableDatas):
|
|
130 |
def fill_codes(self, table, tableDatas):
|
|
132 | 131 |
try: |
133 | 132 |
table.setRowCount(len(tableDatas)) |
134 | 133 |
row = 0 |
... | ... | |
339 | 338 |
def import_code_table(self): |
340 | 339 |
"""import code table excel file""" |
341 | 340 |
|
342 |
pass |
|
341 |
options = QFileDialog.Options() |
|
342 |
options |= QFileDialog.DontUseNativeDialog |
|
343 |
file_name, _ = QFileDialog.getOpenFileName(self, "Import code table", os.getcwd(), "xlsx files(*.xlsx)", |
|
344 |
options=options) |
|
345 |
if file_name: |
|
346 |
QApplication.setOverrideCursor(Qt.WaitCursor) |
|
347 |
try: |
|
348 |
app_doc_data = AppDocData.instance() |
|
349 |
book = load_workbook(file_name) |
|
350 |
for sheet in book.worksheets: |
|
351 |
matches = [index for index in range(self.ui.tabWidget.count()) |
|
352 |
if sheet.title == self.ui.tabWidget.tabText(index)] |
|
353 |
if matches: |
|
354 |
table = self.ui.tabWidget.widget(matches[0]).findChild(QTableWidget) |
|
355 |
self.fill_table_with_sheet(sheet, table) |
|
356 |
except Exception as ex: |
|
357 |
from App import App |
|
358 |
message = 'error occurred({}) in {}:{}'.format(repr(ex), sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
359 |
sys.exc_info()[-1].tb_lineno) |
|
360 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
361 |
finally: |
|
362 |
QApplication.restoreOverrideCursor() |
|
363 |
|
|
343 | 364 |
|
344 | 365 |
def export_code_table(self): |
345 | 366 |
"""export code table to excel file""" |
... | ... | |
413 | 434 |
sys.exc_info()[-1].tb_lineno) |
414 | 435 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
415 | 436 |
|
437 |
def fill_table_with_sheet(self, sheet, table): |
|
438 |
"""fill table with sheet""" |
|
439 |
from NominalPipeSize import NominalPipeSize |
|
440 |
|
|
441 |
try: |
|
442 |
row_index = 0 |
|
443 |
headers = {} |
|
444 |
if sheet.title == 'Nominal Diameter': |
|
445 |
pipe_sizes = [] |
|
446 |
for row in sheet.rows: |
|
447 |
if row_index == 0: |
|
448 |
for col in range(sheet.max_column): |
|
449 |
value = row[col].value |
|
450 |
headers[col] = value |
|
451 |
else: |
|
452 |
pipe_size = NominalPipeSize(None, None, None, None, None, None, None, None) |
|
453 |
for col in range(sheet.max_column): |
|
454 |
value = row[col].value |
|
455 |
if 'Code' == headers[col]: |
|
456 |
pipe_size.code = value |
|
457 |
elif 'Metric' == headers[col]: |
|
458 |
pipe_size.metric = value |
|
459 |
elif 'Inch' == headers[col]: |
|
460 |
pipe_size.inch = value |
|
461 |
elif 'InchStr' == headers[col]: |
|
462 |
pipe_size.inchStr = value |
|
463 |
elif 'Inch Allowables' == headers[col]: |
|
464 |
pipe_size.allowable_inch_str = value |
|
465 |
elif 'MetricStr' == headers[col]: |
|
466 |
pipe_size.metricStr = value |
|
467 |
elif 'Metric Allowables' == headers[col]: |
|
468 |
pipe_size.allowable_metric_str = value |
|
469 |
|
|
470 |
pipe_sizes.append(pipe_size) |
|
471 |
|
|
472 |
row_index += 1 |
|
473 |
|
|
474 |
self.fill_nominal_pipe_sizes(pipe_sizes) |
|
475 |
else: |
|
476 |
codes = [] |
|
477 |
for row in sheet.rows: |
|
478 |
if row_index == 0: |
|
479 |
for col in range(sheet.max_column): |
|
480 |
value = row[col].value |
|
481 |
headers[col] = value |
|
482 |
else: |
|
483 |
code = [row[col].value for col in range(sheet.max_column)] |
|
484 |
codes.append(code) |
|
485 |
|
|
486 |
row_index += 1 |
|
487 |
|
|
488 |
self.fill_codes(table, codes) |
|
489 |
except Exception as ex: |
|
490 |
from App import App |
|
491 |
from AppDocData import MessageType |
|
492 |
|
|
493 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
494 |
sys.exc_info()[-1].tb_lineno) |
|
495 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
496 |
|
|
416 | 497 |
def fill_sheet_with_table(self, table, sheet): |
417 | 498 |
"""fill sheet with table""" |
418 | 499 |
|
DTI_PID/DTI_PID/NominalPipeSize.py | ||
---|---|---|
3 | 3 |
|
4 | 4 |
from SingletonInstance import SingletonInstane |
5 | 5 |
|
6 |
|
|
6 | 7 |
class NominalPipeSizeTable(SingletonInstane): |
7 | 8 |
""" This is nominal pipe size table class """ |
9 |
|
|
8 | 10 |
def __init__(self): |
9 | 11 |
self._pipe_sizes = None |
10 | 12 |
|
... | ... | |
21 | 23 |
|
22 | 24 |
for pipe_size in self.pipe_sizes: |
23 | 25 |
found = pipe_size.find_starts_with(text, size_unit) |
24 |
if found: return found
|
|
26 |
if found: return found |
|
25 | 27 |
|
26 | 28 |
return None |
27 | 29 |
|
... | ... | |
41 | 43 |
""" setter of pipe sizes """ |
42 | 44 |
self._pipe_sizes = value |
43 | 45 |
|
46 |
|
|
44 | 47 |
class NominalPipeSize: |
45 | 48 |
""" This is NominalPipeSize class """ |
49 |
|
|
46 | 50 |
def __init__(self, uid, code, metric, inch, inchStr, allowable_inch_str, metricStr, allowable_metric_str): |
47 | 51 |
self.uid = uid |
48 | 52 |
self.code = code |
... | ... | |
59 | 63 |
@author humkyung |
60 | 64 |
@date 2018.04.24 |
61 | 65 |
''' |
66 |
|
|
62 | 67 |
def find(self, value, size_unit='Inch'): |
63 | 68 |
if size_unit.upper() == 'INCH': |
64 | 69 |
return (self.inchStr == value) or (value in self.allowable_inch_str.split(',')) |
65 | 70 |
elif size_unit.upper() == 'METRIC': |
66 | 71 |
return (self.metricStr == value) or (value in self.allowable_metric_str.split(',')) |
67 | 72 |
else: |
68 |
return (self.inchStr == value) or (value in self.allowable_inch_str.split(',')) or (self.metricStr == value) or (value in self.allowable_metric_str.split(',')) |
|
73 |
return (self.inchStr == value) or (value in self.allowable_inch_str.split(',')) or ( |
|
74 |
self.metricStr == value) or (value in self.allowable_metric_str.split(',')) |
|
69 | 75 |
|
70 | 76 |
def find_starts_with(self, value, size_unit='Inch'): |
71 | 77 |
""" find text start with """ |
... | ... | |
103 | 109 |
|
104 | 110 |
if not self.uid is None: |
105 | 111 |
sql = "update NominalDiameter set Code=?,Metric=?,Inch=?,InchStr=?,AllowableInchStr=?,MetricStr=?,AllowableMetricStr=? where UID=?" |
106 |
param = (self.code, self.metric, self.inch, self.inchStr, self.allowable_inch_str, self.metricStr, self.allowable_metric_str, str(self.uid)) |
|
112 |
param = (self.code, self.metric, self.inch, self.inchStr, self.allowable_inch_str, self.metricStr, |
|
113 |
self.allowable_metric_str, str(self.uid)) |
|
107 | 114 |
res.append((sql, param)) |
108 | 115 |
else: |
109 | 116 |
sql = "insert into NominalDiameter(UID, Code, Metric, Inch, InchStr, AllowableInchStr, MetricStr, AllowableMetricStr) VALUES(?,?,?,?,?,?,?,?)" |
110 |
param = (str(uuid.uuid4()), self.code, self.metric, self.inch, self.inchStr, self.allowable_inch_str, self.metricStr, self.allow_metric_str) |
|
117 |
param = ( |
|
118 |
str(uuid.uuid4()), self.code, self.metric, self.inch, self.inchStr, self.allowable_inch_str, self.metricStr, |
|
119 |
self.allow_metric_str) |
|
111 | 120 |
res.append((sql, param)) |
112 | 121 |
|
113 |
return res |
|
122 |
return res |
DTI_PID/DTI_PID/translate/ko_kr.ts | ||
---|---|---|
1739 | 1739 |
<message> |
1740 | 1740 |
<location filename="../MainWindow_UI.py" line="668"/> |
1741 | 1741 |
<source>Symbol Training</source> |
1742 |
<translation type="unfinished"></translation> |
|
1742 |
<translation type="unfinished">심볼 학습</translation>
|
|
1743 | 1743 |
</message> |
1744 | 1744 |
<message> |
1745 | 1745 |
<location filename="../MainWindow.py" line="713"/> |
내보내기 Unified diff