Skip to content

Commit

Permalink
Replace Tk based file dialog with PyQt5 baed version
Browse files Browse the repository at this point in the history
  • Loading branch information
gb119 committed Mar 22, 2020
1 parent 8dea712 commit 25f0198
Show file tree
Hide file tree
Showing 19 changed files with 4,302 additions and 4,222 deletions.
4,146 changes: 2,073 additions & 2,073 deletions Stoner/Analysis.py

Large diffs are not rendered by default.

7 changes: 2 additions & 5 deletions Stoner/Core.py
Expand Up @@ -1170,7 +1170,7 @@ def __file_dialog(self, mode):
"""
# Wildcard pattern to be used in file dialogs.

descs = {}
descs = {"*.*": "All Files"}
patterns = self.patterns
for p in patterns: # pylint: disable=not-an-iterable
descs[p] = self.__class__.__name__ + " file"
Expand All @@ -1181,9 +1181,6 @@ def __file_dialog(self, mode):
else:
descs[p] = self.subclasses[c].__name__ + " file" # pylint: disable=unsubscriptable-object

patterns = [(descs[p], p) for p in sorted(descs.keys())]
patterns.insert(0, ("All File", "*.*"))

if self.filename is not None:
filename = os.path.basename(self.filename)
dirname = os.path.dirname(self.filename)
Expand All @@ -1196,7 +1193,7 @@ def __file_dialog(self, mode):
mode = "save"
else:
mode = "directory"
dlg = get_filedialog(what=mode, initialdir=dirname, initialfile=filename, filetypes=patterns)
dlg = get_filedialog(what=mode, start=dirname, patterns=descs)
if dlg:
self.filename = dlg
return self.filename
Expand Down
764 changes: 382 additions & 382 deletions Stoner/FileFormats.py

Large diffs are not rendered by default.

62 changes: 31 additions & 31 deletions Stoner/Folders.py
@@ -1,31 +1,31 @@
"""Stoner.Folders : Classes for working collections of :class:`.Data` files.
The core classes provides a means to access them as an ordered collection or as a mapping.
"""
__all__ = ["DataFolder", "PlotFolder"]

from .folders.core import baseFolder
from .folders.mixins import DiskBasedFolder, DataMethodsMixin, PlotMethodsMixin


class DataFolder(DataMethodsMixin, DiskBasedFolder, baseFolder):

"""Provide an interface to manipulating lots of data files stored within a directory structure on disc.
By default, the members of the DataFolder are isntances of :class:`Stoner.Data`. The DataFolder emplys a lazy open strategy, so that
files are only read in from disc when actually needed.
.. inheritance-diagram:: DataFolder
"""

def __init__(self, *args, **kargs):
from Stoner import Data

self.type = kargs.pop("type", Data)
super(DataFolder, self).__init__(*args, **kargs)


class PlotFolder(PlotMethodsMixin, DataFolder):

"""A :py:class:`Stoner.folders.baseFolder` that knows how to ploth its underlying data files."""
"""Stoner.Folders : Classes for working collections of :class:`.Data` files.
The core classes provides a means to access them as an ordered collection or as a mapping.
"""
__all__ = ["DataFolder", "PlotFolder"]

from .folders.core import baseFolder
from .folders.mixins import DiskBasedFolder, DataMethodsMixin, PlotMethodsMixin


class DataFolder(DataMethodsMixin, DiskBasedFolder, baseFolder):

"""Provide an interface to manipulating lots of data files stored within a directory structure on disc.
By default, the members of the DataFolder are isntances of :class:`Stoner.Data`. The DataFolder emplys a lazy open strategy, so that
files are only read in from disc when actually needed.
.. inheritance-diagram:: DataFolder
"""

def __init__(self, *args, **kargs):
from Stoner import Data

self.type = kargs.pop("type", Data)
super(DataFolder, self).__init__(*args, **kargs)


class PlotFolder(PlotMethodsMixin, DataFolder):

"""A :py:class:`Stoner.folders.baseFolder` that knows how to ploth its underlying data files."""
8 changes: 4 additions & 4 deletions Stoner/Image/core.py
Expand Up @@ -1079,10 +1079,10 @@ def __init__(self, *args, **kargs):
elif len(args) > 0 and isinstance(args[0], ImageFile): # Fixing type
self._image = args[0].image
elif len(args) > 0 and isinstance(args[0], np.ndarray): # Fixing type
if isinstance(args[0],ImageArray): #Special handling for ImageArray
self._image=args[0]
self.filename=self._image.filename
self.metadata=self._image.metadata
if isinstance(args[0], ImageArray): # Special handling for ImageArray
self._image = args[0]
self.filename = self._image.filename
self.metadata = self._image.metadata
else:
self._image = ImageArray(*args, **kargs)
elif len(args) > 0 and isinstance(
Expand Down

0 comments on commit 25f0198

Please sign in to comment.