Skip to content

fix #85 : display dtype (in title) #86

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 11, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions larray_editor/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ def setup_and_check(self, data, title='', readonly=False, minvalue=None, maxvalu
title = _("Session viewer") if readonly else _("Session editor")
if readonly:
title += ' (' + _('read only') + ')'
self.title = title
self.setWindowTitle(self.title)
self._title = title
self.setWindowTitle(title)

self.statusBar().showMessage("Welcome to the LArray Viewer", 4000)

Expand Down Expand Up @@ -464,7 +464,9 @@ def on_item_changed(self, curr, prev):

def update_title(self):
array = self.current_array
name = self.current_array_name
name = self.current_array_name if self.current_array_name is not None else ''
dtype = array.dtype.name
unsave_marker = '*' if self._is_unsaved_modifications() else ''
title = []
if isinstance(array, LArray):
# current file (if not None)
Expand All @@ -474,19 +476,17 @@ def update_title(self):
else:
title = [self.current_file]
# array info
axes = array.axes
axes_info = ' x '.join("%s (%d)" % (display_name, len(axis))
for display_name, axis
in zip(axes.display_names, axes))
title += [(name + ': ' + axes_info) if name else axes_info]
# name of non-LArray displayed item (if not None)
elif name:
title = [name]
shape = ['{} ({})'.format(display_name, len(axis))
for display_name, axis in zip(array.axes.display_names, array.axes)]
else:
# if it's not an LArray, it must be a Numpy ndarray
assert isinstance(array, np.ndarray)
shape = [str(length) for length in array.shape]
# name + shape + dtype
array_info = ' x '.join(shape) + ' [{}]'.format(dtype)
title += [unsave_marker + name + ': ' + array_info]
# extra info
title += [self.title]
# add '*' at the end of the title if unsaved modifications.
if self._is_unsaved_modifications():
title += ['*']
title += [self._title]
# set title
self.setWindowTitle(' - '.join(title))

Expand Down