개정판 1fea31e1
issue #1461: UI 수정
Change-Id: I61fc4a324d8aef21d2b8fa6ab1ed14571ca53921
DTI_PID/DTI_PID/HMBDialog.py | ||
---|---|---|
21 | 21 |
def __init__(self, parent): |
22 | 22 |
from HMB_UI import Ui_HMBDialog |
23 | 23 |
from TableWidgetEx import QTableWidgetEx |
24 |
from WaitingSpinnerWidget import QtWaitingSpinner |
|
24 | 25 | |
25 | 26 |
QDialog.__init__(self, parent) |
26 | 27 |
try: |
27 | 28 |
self.ui = Ui_HMBDialog() |
28 | 29 |
self.ui.setupUi(self) |
29 |
#self.ui.buttonBox.button(QDialogButtonBox.Ok).setIcon(QIcon(':/newPrefix/OK.svg')) |
|
30 |
self.waiting_spinner = QtWaitingSpinner(self) |
|
31 |
self.ui.horizontalLayoutSpinnerWaiting.addWidget(self.waiting_spinner) |
|
32 | ||
33 |
self.ui.buttonBox.button(QDialogButtonBox.Ok).setIcon(QIcon(':/newPrefix/OK.svg')) |
|
34 |
self.ui.buttonBox.button(QDialogButtonBox.Ok).setText(self.tr('Import')) |
|
30 | 35 |
self.ui.buttonBox.button(QDialogButtonBox.Close).setIcon(QIcon(':/newPrefix/Remove.svg')) |
31 | 36 | |
32 | 37 |
self.fill_hmb_data(None) |
... | ... | |
76 | 81 |
f"{sys.exc_info()[-1].tb_lineno}" |
77 | 82 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
78 | 83 | |
79 |
def on_open_hmb_file(self): |
|
80 |
"""open hmb file""" |
|
81 |
import math |
|
82 |
import pandas as pd |
|
83 |
from HMBTable import HMBData, StreamData |
|
84 |
class Worker(QThread): |
|
85 |
finished = pyqtSignal() |
|
84 | 86 | |
85 |
options = QFileDialog.Options() |
|
86 |
options |= QFileDialog.DontUseNativeDialog |
|
87 |
file, _ = QFileDialog.getOpenFileName(self, self.tr('Import', "Select Excel File"), |
|
88 |
os.getcwd(), "excel files (*.xlsx)", options=options) |
|
89 |
if file: |
|
90 |
self.ui.lineEditHMBFilePath.setText(file) |
|
87 |
def __init__(self, file_path: str): |
|
88 |
super().__init__() |
|
89 | ||
90 |
self._file_path = file_path |
|
91 | ||
92 |
def run(self): |
|
93 |
"""execute thread""" |
|
94 |
import math |
|
95 |
import pandas as pd |
|
96 |
from HMBTable import HMBData, StreamData |
|
91 | 97 | |
92 | 98 |
hmb_list = [] |
93 |
sheets = pd.read_excel(file, sheet_name=None, header=None, convert_float=False)
|
|
99 |
sheets = pd.read_excel(self._file_path, sheet_name=None, header=None, convert_float=False)
|
|
94 | 100 |
for name, df in sheets.items(): |
95 | 101 |
rows, cols = df.shape[0], df.shape[1] |
96 | 102 |
for col in range(2, cols): |
... | ... | |
122 | 128 |
app_doc_data = AppDocData.instance() |
123 | 129 |
app_doc_data.save_hmb_data(hmb_list) |
124 | 130 | |
125 |
self.fill_hmb_data(None) |
|
131 |
self.finished.emit() |
|
132 | ||
133 |
def on_open_hmb_file(self): |
|
134 |
"""open hmb file""" |
|
135 |
from HMBTable import HMBData, StreamData |
|
136 | ||
137 |
options = QFileDialog.Options() |
|
138 |
options |= QFileDialog.DontUseNativeDialog |
|
139 |
file, _ = QFileDialog.getOpenFileName(self, self.tr('Import', "Select Excel File"), |
|
140 |
os.getcwd(), "excel files (*.xlsx)", options=options) |
|
141 |
if file: |
|
142 |
self.ui.lineEditHMBFilePath.setText(file) |
|
126 | 143 | |
127 | 144 |
def accept(self): |
128 | 145 |
"""no more used""" |
... | ... | |
130 | 147 |
from HMBTable import HMBTable, HMBData |
131 | 148 |
from SymbolAttr import SymbolAttr |
132 | 149 | |
150 |
def on_finished(): |
|
151 |
self.fill_hmb_data(None) |
|
152 |
self.waiting_spinner.stop() |
|
153 | ||
133 | 154 |
try: |
134 |
app_doc_data = AppDocData.instance() |
|
135 |
model = self.ui.tableViewHMB.model() |
|
136 |
app_doc_data.save_hmb_model(model) |
|
137 |
QDialog.accept(self) |
|
155 |
file_path = self.ui.lineEditHMBFilePath.text() |
|
156 |
if file_path: |
|
157 |
self.worker = QHMBDialog.Worker(file_path) |
|
158 |
self.worker.finished.connect(on_finished) |
|
159 |
self.waiting_spinner.start() |
|
160 |
self.worker.start() |
|
161 |
else: |
|
162 |
QMessageBox.warning(self, self.tr('Warning'), self.tr('Please, select a HMB excel file')) |
|
163 | ||
164 |
""" |
|
165 |
app_doc_data = AppDocData.instance() |
|
166 |
model = self.ui.tableViewHMB.model() |
|
167 |
app_doc_data.save_hmb_model(model) |
|
168 |
QDialog.accept(self) |
|
169 |
""" |
|
138 | 170 |
except Exception as ex: |
139 | 171 |
message = f"error occurred({repr(ex)}) in {sys.exc_info()[-1].tb_frame.f_code.co_filename}:" \ |
140 | 172 |
f"{sys.exc_info()[-1].tb_lineno}" |
내보내기 Unified diff