Add download option for hkl/mhkl files
This commit is contained in:
parent
fa73271076
commit
d72c1d478e
@ -8,6 +8,8 @@ from bokeh.layouts import column, row
|
||||
from bokeh.models import (
|
||||
Button,
|
||||
CheckboxGroup,
|
||||
ColumnDataSource,
|
||||
CustomJS,
|
||||
DataRange1d,
|
||||
Div,
|
||||
FileInput,
|
||||
@ -25,11 +27,33 @@ from bokeh.models import (
|
||||
import pyzebra
|
||||
|
||||
|
||||
javaScript = """
|
||||
let j = 0;
|
||||
for (let i = 0; i < js_data.data['fname'].length; i++) {
|
||||
if (js_data.data['content'][i] === "") continue;
|
||||
|
||||
setTimeout(function() {
|
||||
const blob = new Blob([js_data.data['content'][i]], {type: 'text/plain'})
|
||||
const link = document.createElement('a');
|
||||
document.body.appendChild(link);
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
link.href = url;
|
||||
link.download = js_data.data['fname'][i];
|
||||
link.click();
|
||||
window.URL.revokeObjectURL(url);
|
||||
document.body.removeChild(link);
|
||||
}, 100 * j)
|
||||
|
||||
j++;
|
||||
}
|
||||
"""
|
||||
|
||||
def create():
|
||||
ang_lims = None
|
||||
cif_data = None
|
||||
params = None
|
||||
res_files = {}
|
||||
js_data = ColumnDataSource(data=dict(content=[""], fname=[""]))
|
||||
|
||||
anglim_div = Div(text="Angular min/max limits:")
|
||||
sttgamma_ti = TextInput(title="stt/gamma", width=100)
|
||||
@ -223,13 +247,17 @@ def create():
|
||||
sorting_go = Button(label="GO", button_type="primary", width=50)
|
||||
|
||||
def created_lists_callback(_attr, _old, new):
|
||||
preview_lists.value = res_files[new[0]]
|
||||
sel_file = new[0]
|
||||
file_text = res_files[sel_file]
|
||||
preview_lists.value = file_text
|
||||
js_data.data.update(content=[file_text], fname=[sel_file])
|
||||
|
||||
created_lists = MultiSelect(title="Created lists:", width=200, height=150)
|
||||
created_lists.on_change("value", created_lists_callback)
|
||||
preview_lists = TextAreaInput(title="Preview selected list:", width=600, height=150)
|
||||
|
||||
download_file = Button(label="Download file", button_type="success", width=200)
|
||||
download_file.js_on_click(CustomJS(args={"js_data": js_data}, code=javaScript))
|
||||
plot_list = Button(label="Plot selected list", button_type="primary", width=200)
|
||||
|
||||
measured_data_div = Div(text="Measured data:")
|
||||
|
Loading…
x
Reference in New Issue
Block a user