Skip to content

Commit

Permalink
new feature: multiple items can be deleted in the treeview
Browse files Browse the repository at this point in the history
  • Loading branch information
JannickWeisshaupt committed Jun 7, 2018
1 parent 3f1d93e commit c031c36
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
11 changes: 6 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions ocean_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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
Expand Down

0 comments on commit c031c36

Please sign in to comment.