initial qubit-tools
This commit is contained in:
69
qubittool/__main__.py
Normal file
69
qubittool/__main__.py
Normal file
@@ -0,0 +1,69 @@
|
||||
import sys, os
|
||||
import PySimpleGUI as sg
|
||||
|
||||
from tool import read_collect_run_doc_name_strids
|
||||
from tool import read_qubit_doc_by_accession
|
||||
from tool import read_qubit_doc_by_order, write_run_doc
|
||||
|
||||
def make_window():
|
||||
layout = [[sg.Text('Generate RunDoc Output worksheet with Qubit run data.')],
|
||||
[sg.Text('Run Doc: '),
|
||||
sg.Combo(sg.user_settings_get_entry('-filenames1-', []), default_value=sg.user_settings_get_entry('-last filename-', ''), size=(50, 1), key='-FILENAME-'),
|
||||
sg.FileBrowse()],
|
||||
[sg.Text('Qubit Data:'),
|
||||
sg.Combo(sg.user_settings_get_entry('-filenames2-', []), default_value=sg.user_settings_get_entry('-last qbtfilename-', ''), size=(50, 1), key='-QFILENAME-'),
|
||||
sg.FileBrowse()],
|
||||
[sg.Button('Go'), sg.Button('Exit')]]
|
||||
|
||||
return sg.Window('Qubit Tool Window', layout)
|
||||
|
||||
def collect_state_from_serial_accession(values):
|
||||
keys = {}
|
||||
stringpath = values['-FILENAME-']
|
||||
keys = read_collect_run_doc_name_strids(min_col=1, path=stringpath)
|
||||
keys.update(read_collect_run_doc_name_strids(min_col=9, path=stringpath))
|
||||
stringpath = values['-QFILENAME-']
|
||||
read_qubit_doc_by_accession(keys, stringpath)
|
||||
stringpath = values['-FILENAME-']
|
||||
write_run_doc(keys, stringpath)
|
||||
|
||||
def collect_state_from_quibit_order(values):
|
||||
keys = {}
|
||||
stringpath = values['-FILENAME-']
|
||||
keys = read_collect_run_doc_name_strids(min_col=1, path=stringpath)
|
||||
keys.update(read_collect_run_doc_name_strids(min_col=9, path=stringpath))
|
||||
stringpath = values['-QFILENAME-']
|
||||
read_qubit_doc_by_order(keys, stringpath)
|
||||
stringpath = values['-FILENAME-']
|
||||
write_run_doc(keys, stringpath)
|
||||
|
||||
def main():
|
||||
window = make_window()
|
||||
while True:
|
||||
event, values = window.read()
|
||||
|
||||
if event == sg.WIN_CLOSED or event == 'Exit':
|
||||
break
|
||||
if event == 'Go':
|
||||
sg.user_settings_set_entry('-filenames1-', list(set(sg.user_settings_get_entry('-filenames1-', []) + [values['-FILENAME-'], ])))
|
||||
sg.user_settings_set_entry('-last filename-', values['-FILENAME-'])
|
||||
window['-FILENAME-'].update(values=list(set(sg.user_settings_get_entry('-filenames1-', []))))
|
||||
|
||||
sg.user_settings_set_entry('-filenames2-', list(set(sg.user_settings_get_entry('-filenames2-', []) + [values['-QFILENAME-'], ])))
|
||||
sg.user_settings_set_entry('-last qbtfilename-', values['-QFILENAME-'])
|
||||
window['-QFILENAME-'].update(values=list(set(sg.user_settings_get_entry('-filenames2-', []))))
|
||||
|
||||
try:
|
||||
collect_state_from_quibit_order(values)
|
||||
window.Close()
|
||||
except Exception as e:
|
||||
sg.popup_error_with_traceback(f'Error check RunDoc info:', e)
|
||||
|
||||
elif event == 'Clear':
|
||||
sg.user_settings_set_entry('-filenames-', [])
|
||||
sg.user_settings_set_entry('-last filename-', '')
|
||||
window['-FILENAME-'].update(values=[], value='')
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
sys.exit()
|
||||
Reference in New Issue
Block a user