From 9b80e5bb55a70974918e2c89a253ea35ee27ee98 Mon Sep 17 00:00:00 2001 From: ChenglongMa Date: Mon, 29 Jan 2024 23:17:58 +1100 Subject: [PATCH] Fix WinOS paths issues in MultiDirChooser --- gooey/gui/components/widgets/core/chooser.py | 12 +------ gooey/tests/test_chooser_results.py | 37 -------------------- requirements.txt | 2 +- 3 files changed, 2 insertions(+), 49 deletions(-) delete mode 100644 gooey/tests/test_chooser_results.py diff --git a/gooey/gui/components/widgets/core/chooser.py b/gooey/gui/components/widgets/core/chooser.py index 03ba649..2128c38 100644 --- a/gooey/gui/components/widgets/core/chooser.py +++ b/gooey/gui/components/widgets/core/chooser.py @@ -136,17 +136,7 @@ class MultiDirChooser(Chooser): defaultPath=options.get('default_path', os.getcwd()), agwStyle=MDD.DD_MULTIPLE | MDD.DD_DIR_MUST_EXIST) def getResult(self, dialog): - paths = dialog.GetPaths() - # Remove volume labels from Windows paths - if 'nt' == os.name: - for i, path in enumerate(paths): - if path: - parts = path.split(os.sep) - vol = parts[0] - drives = re.match(r'.*\((?P\w:)\)', vol) - paths[i] = os.sep.join([drives.group('drive')] + parts[1:]) - - return os.pathsep.join(paths) + return os.pathsep.join(dialog.GetPaths()) class DateChooser(Chooser): diff --git a/gooey/tests/test_chooser_results.py b/gooey/tests/test_chooser_results.py deleted file mode 100644 index 39e0094..0000000 --- a/gooey/tests/test_chooser_results.py +++ /dev/null @@ -1,37 +0,0 @@ -import argparse -import os -import unittest - -from gooey.gui.components.widgets.core import chooser -from gooey.tests import * - - -class MockWxMDD: - def GetPaths(self): - pass - -class TestChooserResults(unittest.TestCase): - - def test_multiDirChooserGetResult(self): - expected_outputs = [ - (None, "", [""]), - - # Windows - ('nt', "C:", ["OS and System (C:)"]), - ('nt', "D:\\A Folder\\Yep Another One", - ["Other Stuff (D:)\\A Folder\\Yep Another One"]), - ('nt', "A:\\Wow Remember Floppy Drives;E:\\Righto Then", - ["Flipflop (A:)\\Wow Remember Floppy Drives", - "Elephants Only (E:)\\Righto Then"]) - ] - - for osname, expected, pathsoutput in expected_outputs: - if not osname or osname == os.name: - chooser.MDD.MultiDirDialog = MockWxMDD - chooser.MDD.MultiDirDialog.GetPaths = lambda self : pathsoutput - result = chooser.MultiDirChooser.getResult(None, MockWxMDD()) - print(result) - self.assertEqual(result, expected) - -if __name__ == '__main__': - unittest.main() diff --git a/requirements.txt b/requirements.txt index e138af4..f73a815 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -wxpython>=4.1.0 +wxpython>=4.2.1 Pillow>=4.3.0 psutil>=5.4.2 colored>=1.3.93