개정판 0a77ad35
issue #563: inst code table on going test
Change-Id: I5fd074896adab257a8442794828bd35d2a410cb9
DTI_PID/DTI_PID/AppDocData.py | ||
---|---|---|
2158 | 2158 |
sys.exc_info()[-1].tb_lineno) |
2159 | 2159 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
2160 | 2160 |
|
2161 |
def getReplaceTables(self): |
|
2162 |
''' get replace(inst) code tables ''' |
|
2163 |
|
|
2164 |
import uuid |
|
2165 |
from CodeTables import CodeTable |
|
2166 |
|
|
2167 |
with self.project.database.connect() as conn: |
|
2168 |
try: |
|
2169 |
result = [] |
|
2170 |
|
|
2171 |
# Get a cursor object |
|
2172 |
cursor = conn.cursor() |
|
2173 |
|
|
2174 |
sql = self.project.database.to_sql('select UID, Name, Description from InstTables') |
|
2175 |
cursor.execute(sql) |
|
2176 |
rows = cursor.fetchall() |
|
2177 |
for row in rows: |
|
2178 |
table = [] |
|
2179 |
table.append(uuid.UUID(row['UID'])) |
|
2180 |
table.append(row['Name']) |
|
2181 |
table.append(row['Description']) |
|
2182 |
table.append(CodeTable.instance('InstCodes', inst_table_uid=row['UID'])) |
|
2183 |
result.append(table) |
|
2184 |
# Catch the exception |
|
2185 |
except Exception as ex: |
|
2186 |
from App import App |
|
2187 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
2188 |
sys.exc_info()[-1].tb_lineno) |
|
2189 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
2190 |
|
|
2191 |
return result |
|
2192 |
|
|
2161 | 2193 |
def getCustomTables(self): |
2162 | 2194 |
''' get custom code tables ''' |
2163 | 2195 |
|
... | ... | |
2501 | 2533 |
|
2502 | 2534 |
CodeTable.clearTables() |
2503 | 2535 |
|
2536 |
def saveReplaceCodes(self, tables): |
|
2537 |
''' save repalce(inst) code tables and codes ''' |
|
2538 |
|
|
2539 |
from CodeTables import CodeTable |
|
2540 |
|
|
2541 |
conn = self.project.database.connect() |
|
2542 |
with conn: |
|
2543 |
try: |
|
2544 |
# Get a cursor object |
|
2545 |
cursor = conn.cursor() |
|
2546 |
|
|
2547 |
# delete custom codes and tables |
|
2548 |
sql = "delete from InstCodes" |
|
2549 |
cursor.execute(sql) |
|
2550 |
|
|
2551 |
sql = "delete from InstTables" |
|
2552 |
cursor.execute(sql) |
|
2553 |
# up to here |
|
2554 |
|
|
2555 |
# update symbol attribute code table data |
|
2556 |
for table in tables: |
|
2557 |
sql = self.project.database.to_sql("insert into InstTables (UID, Name, Description) VALUES(?,?,?)") |
|
2558 |
param = (table[0], table[1], table[2]) |
|
2559 |
cursor.execute(sql, param) |
|
2560 |
|
|
2561 |
for code in table[3]: |
|
2562 |
sql = self.project.database.to_sql( \ |
|
2563 |
"insert into CustomCodes(UID, Code, Symbols, New Code, Table_UID) VALUES(?,?,?,?,?)") |
|
2564 |
param = (code[0], code[1], ','.join(code[2]), code[3], table[0]) |
|
2565 |
cursor.execute(sql, param) |
|
2566 |
# up to here |
|
2567 |
|
|
2568 |
conn.commit() |
|
2569 |
|
|
2570 |
# Catch the exception |
|
2571 |
except Exception as ex: |
|
2572 |
# Roll back any change if something goes wrong |
|
2573 |
conn.rollback() |
|
2574 |
|
|
2575 |
from App import App |
|
2576 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
2577 |
sys.exc_info()[-1].tb_lineno) |
|
2578 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
2579 |
|
|
2580 |
CodeTable.clearTables() |
|
2581 |
|
|
2504 | 2582 |
''' |
2505 | 2583 |
@brief save symbol attributes |
2506 | 2584 |
@author humkyung |
... | ... | |
2570 | 2648 |
@date 2018.07.10 |
2571 | 2649 |
''' |
2572 | 2650 |
|
2573 |
def getCodeTable(self, property, forCheckLineNumber=False, symbol_attribute_uid=None, custom_table_uid=None, custom=False): |
|
2651 |
def getCodeTable(self, property, forCheckLineNumber=False, symbol_attribute_uid=None, custom_table_uid=None, custom=False, \ |
|
2652 |
inst_table_uid=None, inst=False): |
|
2574 | 2653 |
result = [] |
2575 | 2654 |
with self.project.database.connect() as conn: |
2576 | 2655 |
try: |
... | ... | |
2593 | 2672 |
rows = cursor.fetchall() |
2594 | 2673 |
if property.upper() in [name[0].upper() for name in rows]: |
2595 | 2674 |
""" |
2596 |
if not symbol_attribute_uid and not custom_table_uid and not custom: |
|
2675 |
if not symbol_attribute_uid and not custom_table_uid and not custom and not inst_table_uid:
|
|
2597 | 2676 |
sql = 'select uid, code, description, Allowables from [{}] order by code DESC'.format(property) |
2598 |
elif symbol_attribute_uid and not custom_table_uid: |
|
2677 |
elif symbol_attribute_uid and not custom_table_uid and not inst_table_uid:
|
|
2599 | 2678 |
sql = "select uid, code, description, Allowables from [{}] where SymbolAttribute_UID='{}' " \ |
2600 | 2679 |
"order by code DESC".format(property, symbol_attribute_uid) |
2601 |
elif not symbol_attribute_uid and custom_table_uid: |
|
2680 |
elif not symbol_attribute_uid and custom_table_uid and not inst_table_uid:
|
|
2602 | 2681 |
sql = "select uid, code, description, Allowables from [{}] where Table_UID='{}' " \ |
2603 | 2682 |
"order by code DESC".format(property, custom_table_uid) |
2683 |
elif not symbol_attribute_uid and not custom_table_uid and inst_table_uid: |
|
2684 |
sql = "select uid, code, symbol, newcode from [{}] where Table_UID='{}' " \ |
|
2685 |
"order by code DESC".format(property, inst_table_uid) |
|
2604 | 2686 |
elif custom: |
2605 | 2687 |
sql = "select uid, code, description, Allowables from CustomCodes \ |
2606 | 2688 |
where table_uid = (select uid from CustomTables where upper(name) like upper('{}'))".format(property) |
2689 |
elif isnt: |
|
2690 |
sql = "select uid, code, description, Allowables from InstCodes \ |
|
2691 |
where table_uid = (select uid from InstTables where upper(name) like upper('{}'))".format(property) |
|
2607 | 2692 |
cursor.execute(sql) |
2608 | 2693 |
rows = cursor.fetchall() |
2609 |
for row in rows: |
|
2610 |
if forCheckLineNumber: |
|
2611 |
data = row['code'] |
|
2612 |
else: |
|
2613 |
data = (row['uid'], row['code'], row['description'], row['Allowables']) |
|
2614 |
result.append(data) |
|
2615 |
# else: |
|
2616 |
# result = None |
|
2694 |
if not isnt: |
|
2695 |
for row in rows: |
|
2696 |
if forCheckLineNumber: |
|
2697 |
data = row['code'] |
|
2698 |
else: |
|
2699 |
data = (row['uid'], row['code'], row['description'], row['Allowables']) |
|
2700 |
result.append(data) |
|
2701 |
# else: |
|
2702 |
# result = None |
|
2703 |
else: |
|
2704 |
for row in rows: |
|
2705 |
data = (row['uid'], row['code'], row['symbol'], row['newcode']) |
|
2706 |
result.append(data) |
|
2617 | 2707 |
# Catch the exception |
2618 | 2708 |
except Exception as ex: |
2619 | 2709 |
from App import App |
DTI_PID/DTI_PID/CodeTableDialog.py | ||
---|---|---|
34 | 34 |
|
35 | 35 |
self.code_area = None |
36 | 36 |
self.desc_area = None |
37 |
|
|
38 |
self.inst = False |
|
37 | 39 |
|
38 | 40 |
self.child_dialog = child_dialog |
39 | 41 |
if not child_dialog: |
... | ... | |
241 | 243 |
@date 2018.07.10 |
242 | 244 |
''' |
243 | 245 |
|
244 |
def settingTable(self, tableName, symbol_attribute_uid=None, custom_table_uid=None, tableDatas=None):
|
|
246 |
def settingTable(self, tableName, attribute_uid=None, tableDatas=None):
|
|
245 | 247 |
try: |
246 | 248 |
tableName = self.replaceText(tableName) |
247 | 249 |
docData = AppDocData.instance() |
... | ... | |
251 | 253 |
tableDatas = docData.getNomialPipeSizeData() |
252 | 254 |
elif tableName == "SymbolAttributeCodeTable": |
253 | 255 |
if tableDatas is None: |
254 |
tableDatas = docData.getCodeTable(tableName, forCheckLineNumber=False, symbol_attribute_uid=symbol_attribute_uid)
|
|
256 |
tableDatas = docData.getCodeTable(tableName, forCheckLineNumber=False, symbol_attribute_uid=attribute_uid) |
|
255 | 257 |
else: |
256 | 258 |
pass |
257 | 259 |
elif tableName == 'CustomCodes': |
258 | 260 |
if tableDatas is None: |
259 |
tableDatas = docData.getCodeTable(tableName, forCheckLineNumber=False, custom_table_uid=symbol_attribute_uid) |
|
261 |
tableDatas = docData.getCodeTable(tableName, forCheckLineNumber=False, custom_table_uid=attribute_uid) |
|
262 |
else: |
|
263 |
pass |
|
264 |
elif tableName == 'InstCodes' |
|
265 |
if tableDatas is None: |
|
266 |
tableDatas = docData.getCodeTable(tableName, forCheckLineNumber=False, inst_table_uid=attribute_uid) |
|
260 | 267 |
else: |
261 | 268 |
pass |
262 | 269 |
else: |
... | ... | |
267 | 274 |
|
268 | 275 |
table.cellChanged.connect(self.cellValueChanged) |
269 | 276 |
self.checkRowAndAddRow(tableName, table) |
270 |
else:
|
|
277 |
elif not self.inst:
|
|
271 | 278 |
table.setColumnCount(4) |
272 | 279 |
table.setHorizontalHeaderLabels(['UID', 'Code', 'Desc.', 'Allowables']) |
273 | 280 |
table.hideColumn(0) |
... | ... | |
278 | 285 |
table.cellChanged.connect(self.cellValueChanged) |
279 | 286 |
self.checkRowAndAddRow(tableName, table) |
280 | 287 |
self.setCurrentCode(table, tableName) |
288 |
else: |
|
289 |
table.setColumnCount(4) |
|
290 |
table.setHorizontalHeaderLabels(['UID', 'Code', 'Symbols.', 'New Code']) |
|
291 |
table.hideColumn(0) |
|
292 |
|
|
293 |
self.fill_codes(table, tableDatas) |
|
294 |
|
|
295 |
table.horizontalHeaderItem(1).setSizeHint(QSize(30, 30)) |
|
296 |
table.cellChanged.connect(self.cellValueChanged) |
|
297 |
self.checkRowAndAddRow(tableName, table) |
|
298 |
self.setCurrentCode(table, tableName) |
|
281 | 299 |
except Exception as ex: |
282 | 300 |
print('error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
283 | 301 |
sys.exc_info()[-1].tb_lineno)) |
... | ... | |
334 | 352 |
table.setRowCount(len(tableDatas)) |
335 | 353 |
row = 0 |
336 | 354 |
for tableData in tableDatas: |
337 |
table.setItem(row, 0, QTableWidgetItem(tableData[0])) # UID |
|
338 |
table.setItem(row, 1, QTableWidgetItem(tableData[1])) # Code |
|
339 |
table.setItem(row, 2, QTableWidgetItem(tableData[2] if tableData[2] else '')) # Description |
|
340 |
if not from_exel: |
|
341 |
table.setItem(row, 3, QTableWidgetItem((tableData[3] if type(tableData[3]) is str else ','.join(tableData[3])) \ |
|
342 |
if tableData[3] else '')) # Allowables |
|
355 |
if not self.inst: |
|
356 |
table.setItem(row, 0, QTableWidgetItem(tableData[0])) # UID |
|
357 |
table.setItem(row, 1, QTableWidgetItem(tableData[1])) # Code |
|
358 |
table.setItem(row, 2, QTableWidgetItem(tableData[2] if tableData[2] else '')) # Description |
|
359 |
if not from_exel: |
|
360 |
table.setItem(row, 3, QTableWidgetItem((tableData[3] if type(tableData[3]) is str else ','.join(tableData[3])) \ |
|
361 |
if tableData[3] else '')) # Allowables |
|
362 |
else: |
|
363 |
table.setItem(row, 3, QTableWidgetItem(self.makeAllowable(tableData[1]) if tableData[1] else '')) |
|
343 | 364 |
else: |
344 |
table.setItem(row, 3, QTableWidgetItem(self.makeAllowable(tableData[1]) if tableData[1] else '')) |
|
365 |
table.setItem(row, 0, QTableWidgetItem(tableData[0])) # UID |
|
366 |
table.setItem(row, 1, QTableWidgetItem(tableData[1])) # Code |
|
367 |
table.setItem(row, 2, QTableWidgetItem(','.join(tableData[3]))) # Symbols |
|
368 |
table.setItem(row, 3, QTableWidgetItem(tableData[3])) # New Code |
|
345 | 369 |
|
346 | 370 |
row += 1 |
347 | 371 |
except Exception as ex: |
... | ... | |
547 | 571 |
|
548 | 572 |
table = self.findTableWidget(tabText) |
549 | 573 |
|
550 |
if tabText != "NominalDiameter": |
|
574 |
if tabText != "NominalDiameter" and not self.inst:
|
|
551 | 575 |
item = table.item(row, 1) |
552 | 576 |
if not item: return |
553 | 577 |
code = item.text() |
... | ... | |
572 | 596 |
table.resizeColumnToContents(2) |
573 | 597 |
else: |
574 | 598 |
table.resizeColumnToContents(3) |
599 |
elif self.inst: |
|
600 |
item = table.item(row, 2) |
|
601 |
if not item: return |
|
602 |
code = item.text() |
|
603 |
if code == '': return |
|
604 |
|
|
605 |
self.checkRowAndAddRow(tabText, table) |
|
606 |
self.setCurrentCode(table, tabText) |
|
575 | 607 |
else: |
576 | 608 |
self.checkRowAndAddRow(tabText, table) |
577 | 609 |
except Exception as ex: |
DTI_PID/DTI_PID/CodeTables.py | ||
---|---|---|
14 | 14 |
'VALVEOPERCODES', 'RESERVEDWORDS', 'DICTIONARY', 'EQPTAGNAMES'] |
15 | 15 |
ALLOWABLES = [('1', 'I', 'l'), ('0', 'O'), ('8', 'B'), ('2', 'Z'), ('S', 's', '5')] # must sort long string first ex ('II', '"') for multi-chars, now possible single |
16 | 16 |
|
17 |
def __init__(self, name, values): |
|
17 |
def __init__(self, name, values, inst=False):
|
|
18 | 18 |
self.name = name |
19 |
if self.name != "NOMINALDIAMETER": |
|
19 |
if self.name != "NOMINALDIAMETER" and not inst:
|
|
20 | 20 |
self.values = [] |
21 | 21 |
for x in values: |
22 | 22 |
allowable = x[3].replace(' ', '').split(',') |
... | ... | |
26 | 26 |
self.values.append((x[0], x[1], x[2], [allowable[0]] + sorted(allowable[1:], key=lambda param:len(param), reverse=True))) |
27 | 27 |
|
28 | 28 |
self.values = sorted(self.values, key=lambda param:len(param[1]), reverse=True) |
29 |
elif inst: |
|
30 |
self.values = [] |
|
31 |
for x in values: |
|
32 |
symbols = [symbol.strip() for symbol in x[2].split(',')] |
|
33 |
self.values.append((x[0], x[1], symbols, x[3])) |
|
29 | 34 |
else: |
30 | 35 |
self.values = values |
31 | 36 |
|
... | ... | |
109 | 114 |
return None |
110 | 115 |
|
111 | 116 |
@staticmethod |
112 |
def instance(table_name, symbol_attribute_uid=None, custom_table_uid=None): |
|
117 |
def instance(table_name, symbol_attribute_uid=None, custom_table_uid=None, inst_table_uid=None, inst=False):
|
|
113 | 118 |
""" return instance has given table name """ |
114 | 119 |
|
115 | 120 |
from NominalPipeSize import NominalPipeSizeTable |
... | ... | |
146 | 151 |
CodeTable.TABLES[custom_table_uid] = CodeTable(custom_table_uid, values) |
147 | 152 |
return CodeTable.TABLES[custom_table_uid] |
148 | 153 |
|
149 |
elif _table_name not in CodeTable.TABLES: |
|
154 |
elif _table_name == 'INSTCODES' and inst_table_uid: |
|
155 |
# replace code table setting |
|
156 |
if inst_table_uid in CodeTable.TABLES: |
|
157 |
return CodeTable.TABLES[inst_table_uid] |
|
158 |
else: |
|
159 |
appDocData = AppDocData.instance() |
|
160 |
values = appDocData.getCodeTable(_table_name, False, inst_table_uid=inst_table_uid, inst=True) |
|
161 |
CodeTable.TABLES[inst_table_uid] = CodeTable(inst_table_uid, values, inst=True) |
|
162 |
return CodeTable.TABLES[inst_table_uid] |
|
163 |
|
|
164 |
elif _table_name not in CodeTable.TABLES and not inst: |
|
150 | 165 |
# custom code table using |
151 | 166 |
appDocData = AppDocData.instance() |
152 | 167 |
values = appDocData.getCodeTable(_table_name, False, custom=True) |
153 | 168 |
CodeTable.TABLES[_table_name] = CodeTable(custom_table_uid, values) |
154 | 169 |
return CodeTable.TABLES[_table_name] |
170 |
|
|
171 |
elif _table_name not in CodeTable.TABLES and inst: |
|
172 |
# custom code table using |
|
173 |
appDocData = AppDocData.instance() |
|
174 |
values = appDocData.getCodeTable(_table_name, False, inst=True) |
|
175 |
CodeTable.TABLES[_table_name] = CodeTable(custom_table_uid, values, inst=True) |
|
176 |
return CodeTable.TABLES[_table_name] |
|
155 | 177 |
|
156 | 178 |
return CodeTable.TABLES[_table_name] |
157 | 179 |
|
DTI_PID/DTI_PID/CustomCodeTablesDialog.py | ||
---|---|---|
12 | 12 |
import CustomCodeTables_UI |
13 | 13 |
|
14 | 14 |
class CustomCodeTablesDialog(QDialog): |
15 |
def __init__(self, parent): |
|
15 |
def __init__(self, parent, replace=False):
|
|
16 | 16 |
QDialog.__init__(self, parent) |
17 | 17 |
|
18 | 18 |
self.ui = CustomCodeTables_UI.Ui_CustomCodeTables() |
... | ... | |
26 | 26 |
self.ui.tableWidgetCustomCodeTable.horizontalHeader().setStretchLastSection(True) |
27 | 27 |
|
28 | 28 |
self.isAccepted = False |
29 |
|
|
30 |
self.replace = replace |
|
29 | 31 |
|
30 | 32 |
self.ui.buttonBox.accepted.connect(self.accept) |
31 | 33 |
self.ui.buttonBox.rejected.connect(self.reject) |
... | ... | |
33 | 35 |
self.ui.pushButtonDelete.clicked.connect(self.delTable) |
34 | 36 |
self.ui.tableWidgetCustomCodeTable.cellDoubleClicked.connect(self.cell_double_clicked) |
35 | 37 |
|
38 |
if self.replace: |
|
39 |
self.setWindowTitle('Replace Code Tables') |
|
40 |
self.ui.groupBoxTitleBlock.setTitle('Replace Talbes') |
|
41 |
|
|
36 | 42 |
self.loadData() |
37 | 43 |
|
38 | 44 |
def loadData(self): |
... | ... | |
40 | 46 |
|
41 | 47 |
appDocData = AppDocData.instance() |
42 | 48 |
|
43 |
tables = appDocData.getCustomTables() |
|
49 |
if not self.replace: |
|
50 |
tables = appDocData.getCustomTables() |
|
51 |
else: |
|
52 |
tables = appDocData.getReplaceTables() |
|
44 | 53 |
self.ui.tableWidgetCustomCodeTable.setRowCount(len(tables)) |
45 | 54 |
|
46 | 55 |
row = 0 |
... | ... | |
68 | 77 |
|
69 | 78 |
try: |
70 | 79 |
if column == 3: |
71 |
dialog = SymbolAttrCodeTableDialog(self, self.ui.tableWidgetCustomCodeTable.item(row, 0).text(), tableDatas=self.ui.tableWidgetCustomCodeTable.item(row, 3).tag, Table_Name='CustomCodes') |
|
80 |
if not self.replace: |
|
81 |
dialog = SymbolAttrCodeTableDialog(self, self.ui.tableWidgetCustomCodeTable.item(row, 0).text(), tableDatas=self.ui.tableWidgetCustomCodeTable.item(row, 3).tag, Table_Name='CustomCodes') |
|
82 |
else: |
|
83 |
dialog = SymbolAttrCodeTableDialog(self, self.ui.tableWidgetCustomCodeTable.item(row, 0).text(), tableDatas=self.ui.tableWidgetCustomCodeTable.item(row, 3).tag, Table_Name='InstCodes') |
|
72 | 84 |
(isAccept, code_data) = dialog.showDialog() |
73 | 85 |
|
74 | 86 |
if isAccept: |
... | ... | |
134 | 146 |
attr.append(table.item(index, 3).tag if table.item(index, 3) is not None else []) |
135 | 147 |
tables.append(attr) |
136 | 148 |
|
137 |
appDocData.saveCustomCodes(tables) |
|
149 |
if not self.replace: |
|
150 |
appDocData.saveCustomCodes(tables) |
|
151 |
else: |
|
152 |
appDocData.saveReplaceCodes(tables) |
|
138 | 153 |
|
139 | 154 |
self.isAccepted = True |
140 | 155 |
QDialog.accept(self) |
DTI_PID/DTI_PID/MainWindow.py | ||
---|---|---|
247 | 247 |
self.actionOPCRelation.triggered.connect(self.on_show_opc_relation) # show OPC Relation dialog |
248 | 248 |
self.actionCodeTable.triggered.connect(self.onShowCodeTable) |
249 | 249 |
self.actionCustom_Code_Table.triggered.connect(self.onShowCustomCodeTable) |
250 |
self.actionReplace_Code_Table.triggered.connect(self.onShowReplaceCodeTable) |
|
250 | 251 |
self.actionImage_Drawing.triggered.connect(self.onViewImageDrawing) |
251 | 252 |
self.actionDrawing_Only.triggered.connect(self.onViewDrawingOnly) |
252 | 253 |
self.actionValidate.triggered.connect(self.onValidation) |
... | ... | |
1350 | 1351 |
dlg.exec_() |
1351 | 1352 |
self.graphicsView.useDefaultCommand() |
1352 | 1353 |
|
1354 |
def onShowReplaceCodeTable(self): |
|
1355 |
from CustomCodeTablesDialog import CustomCodeTablesDialog |
|
1356 |
|
|
1357 |
dlg = CustomCodeTablesDialog(self, replace=True) |
|
1358 |
dlg.show() |
|
1359 |
dlg.exec_() |
|
1360 |
self.graphicsView.useDefaultCommand() |
|
1361 |
|
|
1353 | 1362 |
''' |
1354 | 1363 |
@brief show HMB data |
1355 | 1364 |
@author humkyung |
DTI_PID/DTI_PID/MainWindow_UI.py | ||
---|---|---|
1 | 1 |
# -*- coding: utf-8 -*- |
2 | 2 |
|
3 |
# Form implementation generated from reading ui file '.\UI\MainWindow.ui'
|
|
3 |
# Form implementation generated from reading ui file './UI/MainWindow.ui'
|
|
4 | 4 |
# |
5 |
# Created by: PyQt5 UI code generator 5.13.1
|
|
5 |
# Created by: PyQt5 UI code generator 5.11.3
|
|
6 | 6 |
# |
7 | 7 |
# WARNING! All changes made in this file will be lost! |
8 | 8 |
|
9 |
|
|
10 | 9 |
from PyQt5 import QtCore, QtGui, QtWidgets |
11 | 10 |
|
12 |
|
|
13 | 11 |
class Ui_MainWindow(object): |
14 | 12 |
def setupUi(self, MainWindow): |
15 | 13 |
MainWindow.setObjectName("MainWindow") |
... | ... | |
592 | 590 |
icon28.addPixmap(QtGui.QPixmap(":/newPrefix/Rotate_Minus.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off) |
593 | 591 |
self.actionRotateCCW.setIcon(icon28) |
594 | 592 |
self.actionRotateCCW.setObjectName("actionRotateCCW") |
593 |
self.actionReplace_Code_Table = QtWidgets.QAction(MainWindow) |
|
594 |
self.actionReplace_Code_Table.setIcon(icon15) |
|
595 |
self.actionReplace_Code_Table.setObjectName("actionReplace_Code_Table") |
|
595 | 596 |
self.menuExport.addAction(self.actionExportAsSVG) |
596 | 597 |
self.menuExport.addAction(self.actionExportAsXML) |
597 | 598 |
self.menuExport.addAction(self.actionExportAsImage) |
... | ... | |
613 | 614 |
self.menu_2.addSeparator() |
614 | 615 |
self.menu_2.addAction(self.actionCodeTable) |
615 | 616 |
self.menu_2.addAction(self.actionCustom_Code_Table) |
617 |
self.menu_2.addAction(self.actionReplace_Code_Table) |
|
616 | 618 |
self.menu_2.addSeparator() |
617 | 619 |
self.menu_2.addAction(self.actionOCR_Training) |
618 | 620 |
self.menu_2.addAction(self.actionSymbol_Training) |
... | ... | |
797 | 799 |
self.actionMake_Label_Data.setText(_translate("MainWindow", "Make Label Data")) |
798 | 800 |
self.actionRotateCCW.setText(_translate("MainWindow", "RotateCCW")) |
799 | 801 |
self.actionRotateCCW.setToolTip(_translate("MainWindow", "Roate counter clockwise")) |
802 |
self.actionReplace_Code_Table.setText(_translate("MainWindow", "Replace Code Table")) |
|
803 |
|
|
800 | 804 |
import MainWindow_rc |
805 |
|
|
806 |
if __name__ == "__main__": |
|
807 |
import sys |
|
808 |
app = QtWidgets.QApplication(sys.argv) |
|
809 |
MainWindow = QtWidgets.QMainWindow() |
|
810 |
ui = Ui_MainWindow() |
|
811 |
ui.setupUi(MainWindow) |
|
812 |
MainWindow.show() |
|
813 |
sys.exit(app.exec_()) |
|
814 |
|
DTI_PID/DTI_PID/SymbolAttrCodeTableDialog.py | ||
---|---|---|
15 | 15 |
|
16 | 16 |
class SymbolAttrCodeTableDialog(QCodeTableDialog): |
17 | 17 |
# custom code table also use this class |
18 |
def __init__(self, parent, symbol_attribute_uid, tableDatas=None, Table_Name='SymbolAttributeCodeTable'):
|
|
18 |
def __init__(self, parent, attribute_uid, tableDatas=None, Table_Name='SymbolAttributeCodeTable'): |
|
19 | 19 |
QCodeTableDialog.__init__(self, parent, Table_Name) |
20 | 20 |
|
21 | 21 |
self.ui = SymbolAttrCodeTable_UI.Ui_AttributeCodeTable() |
... | ... | |
32 | 32 |
self.ui.buttonBox.rejected.connect(self.reject) |
33 | 33 |
|
34 | 34 |
# for custom code table |
35 |
if Table_Name != 'SymbolAttributeCodeTable':
|
|
35 |
if Table_Name != 'CustomCodes':
|
|
36 | 36 |
self.setWindowTitle('Custom Code Table') |
37 | 37 |
self.ui.tableWidgetSymbolAttributeCodeTable.setObjectName('tableWidget' + Table_Name) |
38 |
elif Table_Name != 'InstCodes': |
|
39 |
self.setWindowTitle('Replace Code Table') |
|
40 |
self.ui.tableWidgetSymbolAttributeCodeTable.setObjectName('tableWidget' + Table_Name) |
|
41 |
self.inst = True |
|
42 |
|
|
43 |
self.ui.checkBoxAllowable.setHidden(True) |
|
44 |
self.ui.label.setHidden(True) |
|
45 |
self.ui.spinBoxHeight.setHidden(True) |
|
46 |
self.ui.pushButtonRead.setHidden(True) |
|
38 | 47 |
|
39 |
self.settingTable(Table_Name, symbol_attribute_uid=symbol_attribute_uid, tableDatas=tableDatas)
|
|
48 |
self.settingTable(Table_Name, attribute_uid=attribute_uid, tableDatas=tableDatas)
|
|
40 | 49 |
|
41 | 50 |
''' |
42 | 51 |
@brief accept dialog |
... | ... | |
56 | 65 |
continue |
57 | 66 |
else: |
58 | 67 |
uid = table.item(row, 0).text() if table.item(row, 0).text() else str(uuid.uuid4()) |
59 |
code = table.item(row, 1).text() |
|
68 |
code = table.item(row, 1).text() if table.item(row, 1) else ''
|
|
60 | 69 |
description = table.item(row, 2).text() if table.item(row, 2) is not None else '' |
61 | 70 |
allowables = table.item(row, 3).text().split(',') if table.item(row, 3) is not None else [] |
62 | 71 |
|
DTI_PID/DTI_PID/UI/MainWindow.ui | ||
---|---|---|
105 | 105 |
<addaction name="separator"/> |
106 | 106 |
<addaction name="actionCodeTable"/> |
107 | 107 |
<addaction name="actionCustom_Code_Table"/> |
108 |
<addaction name="actionReplace_Code_Table"/> |
|
108 | 109 |
<addaction name="separator"/> |
109 | 110 |
<addaction name="actionOCR_Training"/> |
110 | 111 |
<addaction name="actionSymbol_Training"/> |
... | ... | |
1243 | 1244 |
</action> |
1244 | 1245 |
<action name="actionExportAsSVG"> |
1245 | 1246 |
<property name="icon"> |
1246 |
<iconset resource="../res/MainWindow.qrc">
|
|
1247 |
<iconset> |
|
1247 | 1248 |
<normaloff>:/newPrefix/svg.png</normaloff>:/newPrefix/svg.png</iconset> |
1248 | 1249 |
</property> |
1249 | 1250 |
<property name="text"> |
... | ... | |
1332 | 1333 |
<string>Roate counter clockwise</string> |
1333 | 1334 |
</property> |
1334 | 1335 |
</action> |
1336 |
<action name="actionReplace_Code_Table"> |
|
1337 |
<property name="icon"> |
|
1338 |
<iconset resource="../res/MainWindow.qrc"> |
|
1339 |
<normaloff>:/newPrefix/codetable.png</normaloff>:/newPrefix/codetable.png</iconset> |
|
1340 |
</property> |
|
1341 |
<property name="text"> |
|
1342 |
<string>Replace Code Table</string> |
|
1343 |
</property> |
|
1344 |
</action> |
|
1335 | 1345 |
</widget> |
1336 | 1346 |
<resources> |
1337 | 1347 |
<include location="../res/MainWindow.qrc"/> |
내보내기 Unified diff