Skip to content

Commit c12344b

Browse files
authored
Merge pull request #11 from kiyu-git/PyQt5
PyQt5更新
2 parents 5f0eee8 + 8114234 commit c12344b

File tree

2 files changed

+27
-13
lines changed

2 files changed

+27
-13
lines changed

main.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,15 @@ def load_new_file(self, idx):
164164
self.InputFiles.setCurrentText(droppdown_item_labels[self.pre_file_idx])
165165
self.InputFiles.blockSignals(False)
166166
else:
167+
# validation
168+
folder_paths = tools.get_latest_folder_paths(dir)
169+
if len(folder_paths) == 0:
170+
logger.info("########\nError: フォルダーが無効です。")
171+
# 再度QFileDialogを表示
172+
self.load_new_file(idx)
173+
return
167174
self.dir_path = dir
168-
self.folder_paths = tools.get_latest_folder_paths(self.dir_path)
175+
self.folder_paths = folder_paths
169176
path_latest_folder: str = self.folder_paths[0]
170177
self.folder_path = path_latest_folder
171178
self.droppdown_items = tools.make_droppdown_item(self.folder_paths)
@@ -304,21 +311,24 @@ def init_variables(self, _settings, _measurement_settings):
304311

305312
def set_view_area(self, _setX=True, _setY=True):
306313
self.graphs["signals"]["graphic"].setLimits(
307-
xMin=0,
308-
xMax=sys.float_info.max,
309-
yMin=sys.float_info.min,
310-
yMax=sys.float_info.max,
314+
xMin=None,
315+
xMax=None,
316+
yMin=None,
317+
yMax=None,
311318
)
312319
if _setX:
313320
self.graphs["range"]["region"].setRegion(
314321
[self.data.index[0], self.data.index[-1]]
315322
)
316323
self.graphs["signals"]["graphic"].enableAutoRange(axis="y")
317324
self.graphs["signals"]["graphic"].setAutoVisible(y=True)
318-
view = self.graphs["signals"]["graphic"].viewRange()
319-
self.graphs["signals"]["graphic"].setLimits(
320-
xMin=view[0][0], xMax=view[0][1], yMin=view[1][0], yMax=view[1][1]
321-
)
325+
# Issue #7の対応でコメントアウト
326+
# self.graphs["signals"]["graphic"].viewRange()の計算がおかしいことが原因と思われる
327+
# view = self.graphs["signals"]["graphic"].viewRange()
328+
# print(view)
329+
# self.graphs["signals"]["graphic"].setLimits(
330+
# xMin=view[0][0], xMax=view[0][1], yMin=view[1][0], yMax=view[1][1]
331+
# )
322332

323333
def set_graph_ui(self) -> dict:
324334
"""

tools.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@
55

66
def get_latest_folder_paths(dirname):
77
target = os.path.join(dirname, "*")
8-
files = [(f, os.path.getmtime(f)) for f in glob(target)]
9-
# ファイルの名前を参照して並べ替え
10-
file_paths = [path for path, file in sorted(files, reverse=True)]
11-
return file_paths
8+
folders = [f for f in glob(target) if os.path.isdir(f)]
9+
# フォルダの名前を参照して並べ替え / .csvファイルを内包するファイルのみ抽出
10+
folder_paths = [
11+
path
12+
for path in sorted(folders, reverse=True)
13+
if os.path.isfile(get_csv_path(path))
14+
]
15+
return folder_paths
1216

1317

1418
def get_csv_path(_path_folder: str) -> str:

0 commit comments

Comments
 (0)