Browse Source

Use natsort.os_sorted to sort files in the browser

Kentaro Wada 3 năm trước cách đây
mục cha
commit
4d4cd2033e
2 tập tin đã thay đổi với 3 bổ sung1 xóa
  1. 2 1
      labelme/app.py
  2. 1 0
      setup.py

+ 2 - 1
labelme/app.py

@@ -8,6 +8,7 @@ import re
 import webbrowser
 
 import imgviz
+import natsort
 from qtpy import QtCore
 from qtpy.QtCore import Qt
 from qtpy import QtGui
@@ -2062,5 +2063,5 @@ class MainWindow(QtWidgets.QMainWindow):
                 if file.lower().endswith(tuple(extensions)):
                     relativePath = osp.join(root, file)
                     images.append(relativePath)
-        images.sort(key=lambda x: x.lower())
+        images = natsort.os_sorted(images)
         return images

+ 1 - 0
setup.py

@@ -31,6 +31,7 @@ def get_install_requires():
     install_requires = [
         "imgviz>=0.11",
         "matplotlib<3.3",  # for PyInstaller
+        "natsort>=7.1.0",
         "numpy",
         "Pillow>=2.8",
         "PyYAML",