From c031c36a5da873f582e8faf05905ea53a0340584 Mon Sep 17 00:00:00 2001 From: jannickweisshaupt Date: Thu, 7 Jun 2018 15:09:10 +0200 Subject: [PATCH] new feature: multiple items can be deleted in the treeview --- main.py | 11 ++++++----- ocean_handlers.py | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/main.py b/main.py index 4154a30..7026812 100755 --- a/main.py +++ b/main.py @@ -1160,16 +1160,17 @@ def __init__(self, Visualizer, data_dictionary, parent=None, selection_mode=None self.show() def delete_selected_item(self): - index = self.treeview.selectedIndexes()[0] - item = self.treeview.itemFromIndex(index) - bs_name = item.text(0) + indexes = self.treeview.selectedIndexes() + items = [self.treeview.itemFromIndex(index) for index in indexes] + bs_names = [item.text(0) for item in items] - del_msg = "Are you sure you want to delete " + bs_name + ' permanently?' + del_msg = "Are you sure you want to delete " + ', '.join(bs_names) + ' permanently?' reply = QtGui.QMessageBox.question(self, 'Sure to delete?', del_msg, QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) if reply == QtGui.QMessageBox.Yes: - del self.data_dictionary[bs_name] + for bs_name in bs_names: + del self.data_dictionary[bs_name] self.update_tree() def export_selected_item(self, code=False): diff --git a/ocean_handlers.py b/ocean_handlers.py index 20a0639..70bc764 100644 --- a/ocean_handlers.py +++ b/ocean_handlers.py @@ -331,7 +331,7 @@ def read_optical_spectrum(self): width = float(self.optical_spectrum_options['edge width']) A0 = float(self.optical_spectrum_options['edge amplitude']) - edge_f = lambda E: A0*(scipy.special.erf((E - Ek) / width) + 1)/2 / (E / Ek) ** 3 + edge_f = lambda E: (scipy.special.erf((E - Ek) / width) + 1)/2 / (E / Ek) ** 4 region = E.max()-E.min() @@ -341,7 +341,7 @@ def read_optical_spectrum(self): edge = edge_f(E_plot) exaf_interp = np.interp(E_plot, E, data[:, 1], left=0) - res_abs = exaf_interp + edge + res_abs = A0*(exaf_interp + edge) # c = 299792458 # omega = E_plot*e/hbar # eps2 = res_abs*1e6*c/omega