def _build_Canvas_columns(vip, tb): from widgets.ResultCanvas_QTAgg import Canvas2dData, Canvas3dData vip.Canvas[tb]['2d_data'] = Canvas2dData(tb, vip) vip.Canvas[tb]['3d_data'] = Canvas3dData(tb, vip) ########## ########## vip.content['captions'][tb]['lb'] = {'_lb_data_set' : "Data set" ,'_lb_plot_function' : "with 3d data plotted as" } vip.content['captions'][tb]['bn'] = {} vip.content['captions'][tb]['cb'] = {'B_keep_updated' : "Update "+tb} vip.content['events'][tb]['le'] = {} vip.content['events'][tb]['cb'] = {'B_keep_updated' : lambda state: se.cb_toggled(vip, tb, 'B_keep_updated')} vip.content['events'][tb]['dm'] = {'F_data_set' : lambda text: se.dm_plot_canvas_change(vip, tb, 'F_data_set' , text) ,'F_plot_function' : lambda text: se.dm_plot_canvas_change(vip, tb, 'F_plot_function', text) } vip.content['events'][tb]['bn'] = {} vip.content['cb_vals'][tb] = {'B_keep_updated' : ('ON', 'OFF')} vip.content['dm_vals'][tb] = {'F_data_set' : menus.DATA_SET_KEYS ,'F_plot_function' : menus.PLOT_FUNCTION_KEYS } sw.__fill_widgets(vip, tb, fontsize=cs.FONTSIZE-2) #### ---------- colours = {'Plot_column_1' : {'2d_data' : cs.COLOR_TRACE_1, '3d_data' : cs.COLOR_DENSITY_1} ,'Plot_column_2' : {'2d_data' : cs.COLOR_TRACE_2, '3d_data' : cs.COLOR_DENSITY_2} ,'Plot_column_3' : {'2d_data' : cs.COLOR_TRACE_3, '3d_data' : cs.COLOR_DENSITY_3} ,'Plot_column_4' : {'2d_data' : cs.COLOR_TRACE_4, '3d_data' : cs.COLOR_DENSITY_4} } for plot_type, color in colours[tb].iteritems(): vip.Canvas[tb][plot_type]._Figure.set_facecolor(color) ########## ########## hBoxs hBox = QtGui.QHBoxLayout() hBox.addWidget(vip._qWidgets['cb'][tb]['B_keep_updated']) hBox.addLayout(vip._blanks.next()) hBox.addStretch(.1) hBox.addWidget(vip._qWidgets['lb'][tb]['_lb_data_set']) hBox.addWidget(vip._qWidgets['dm'][tb]['F_data_set']) hBox.addWidget(vip._qWidgets['lb'][tb]['_lb_plot_function']) hBox.addWidget(vip._qWidgets['dm'][tb]['F_plot_function']) ########## ########## vBo vBox = QtGui.QVBoxLayout(vip._qWidgets['qw'][tb]) vBox.addWidget(vip.Canvas[tb]['2d_data']) vBox.addWidget(vip.Canvas[tb]['3d_data']) vBox.addLayout(vip._blanks.next()) vBox.addLayout(hBox)
def _build_Meas_main(vip): tb = 'Meas_main' vip.content['captions'][tb]['lb'] = {} vip.content['captions'][tb]['bn'] = {} vip.content['captions'][tb]['cb'] = { 'B_during_sweep_1': "Measure during sweep 1:" } vip.content['events'][tb]['le'] = {} vip.content['events'][tb]['cb'] = { 'B_during_sweep_1': lambda state: se.cb_toggled(vip, tb, 'B_during_sweep_1') } vip.content['events'][tb]['dm'] = { 'meas_type': lambda text: se.le_or_dm_change(vip, tb, 'meas_type', text) } vip.content['events'][tb]['bn'] = {} vip.content['cb_vals'][tb] = {'B_during_sweep_1': ('ON', 'OFF')} vip.content['dm_vals'][tb] = { 'meas_type': session.Tree['_Routines']['Traces'].keys() + session.Tree['_Routines']['Points'].keys() } sw.__fill_widgets(vip, tb) #### ---------- vip._qWidgets['cb'][tb]['B_during_sweep_1'].setFont( QtGui.QFont(cs.FONT, cs.FONTSIZE + 1)) vip._qWidgets['dm'][tb]['meas_type'].setFont( QtGui.QFont(cs.FONT, cs.FONTSIZE + 1)) ########## ########## hBoxs hBox2 = QtGui.QHBoxLayout() hBox2.addStretch(1) hBox2.addWidget(vip._qWidgets['dm'][tb]['meas_type']) hBox2.addStretch(1) ########## ########## vBo vBox = QtGui.QVBoxLayout(vip._qWidgets['qw'][tb]) vBox.addLayout(hBox2)
def _build_I_Q_point(vip): from interface.session_widgets import sweep_ks tb = 'I Q point' vip.content['captions'][tb]['lb'] = { 'F_instr_name': "Measurement instrument:", 'F_frequency_shift': "Frequency shift:", '_lb_unit_freq': "[see sweep]" } vip.content['captions'][tb]['bn'] = {} vip.content['captions'][tb]['cb'] = { 'B_lock_to_freq': "Lock center frequency to:" } vip.content['events'][tb]['le'] = { 'F_frequency_shift': lambda text: se.le_or_dm_change(vip, tb, 'F_frequency_shift', text) } vip.content['events'][tb]['dm'] = { 'F_instr_name': lambda text: se.le_or_dm_change(vip, tb, 'F_instr_name', text), 'F_lock_to_sweep': lambda text: se.le_or_dm_change(vip, tb, 'F_lock_to_sweep', text) } vip.content['events'][tb]['bn'] = {} vip.content['events'][tb]['cb'] = { 'B_lock_to_freq': lambda state: se.cb_toggled(vip, tb, 'B_lock_to_freq') } vip.content['cb_vals'][tb] = {'B_lock_to_freq': ('ON', 'OFF')} vip.content['dm_vals'][tb] = { 'F_instr_name': session.instr_classification[ 'VNA'] # session.instr_classification['SG']+session.instr_classification['VNA']+ , 'F_lock_to_sweep': sweep_ks( 'Freq.' ) # session.instr_classification['SG']+session.instr_classification['VNA']+ } sw.__fill_widgets(vip, tb, fontsize=cs.FONTSIZE - 1) ########## ########## hBoxs dm_ks = ['F_instr_name'] le_ks = ['F_frequency_shift'] cb_ks = ['_F_lock_to_sweep'] ks = dm_ks + cb_ks + le_ks hBoxs = {k: QtGui.QHBoxLayout() for k in ks} for k in le_ks: hBoxs[k].addWidget(vip._qWidgets['lb'][tb][k]) hBoxs[k].addStretch(.1) hBoxs[k].addWidget(vip._qWidgets['le'][tb][k]) hBoxs['F_frequency_shift'].addWidget( vip._qWidgets['lb'][tb]['_lb_unit_freq']) for k in dm_ks: hBoxs[k].addWidget(vip._qWidgets['lb'][tb][k]) hBoxs[k].addStretch(.1) hBoxs[k].addWidget(vip._qWidgets['dm'][tb][k]) hBoxs['_F_lock_to_sweep'].addWidget( vip._qWidgets['cb'][tb]['B_lock_to_freq']) hBoxs['_F_lock_to_sweep'].addStretch(.1) hBoxs['_F_lock_to_sweep'].addWidget( vip._qWidgets['dm'][tb]['F_lock_to_sweep']) ########## ########## vBox vBox = QtGui.QVBoxLayout(vip._qWidgets['qw'][tb]) for k in ks: vBox.addLayout(hBoxs[k])
def _build_Sweep(vip): tb = 'Sweep' import interface.measurement as measurement vip.content['captions'][tb]['lb'] = {} vip.content['captions'][tb]['bn'] = { '_bn_do_sweep': cs.BLANK + "Do sweep" + cs.BLANK, '_bn_stop': cs.BLANK + "Stop" + cs.BLANK } vip.content['captions'][tb]['cb'] = { 'B_is_max_1': "Single sweep", 'B_is_max_2': "Double sweep", 'B_is_max_3': "Triple trouble", 'B_find_min': "Get minimum" } vip.content['events'][tb]['le'] = {} vip.content['events'][tb]['cb'] = { 'B_is_max_1': lambda state: se.cb_toggled(vip, tb, 'B_is_max_1'), 'B_is_max_2': lambda state: se.cb_toggled(vip, tb, 'B_is_max_2'), 'B_is_max_3': lambda state: se.cb_toggled(vip, tb, 'B_is_max_3'), 'B_find_min': lambda state: se.cb_toggled(vip, tb, 'B_find_min') } vip.content['events'][tb]['dm'] = { 'sweep_title_1': lambda text: se.le_or_dm_change(vip, tb, 'sweep_title_1', text), 'sweep_title_2': lambda text: se.le_or_dm_change(vip, tb, 'sweep_title_2', text), 'sweep_title_3': lambda text: se.le_or_dm_change(vip, tb, 'sweep_title_3', text) } vip.content['events'][tb]['bn'] = { '_bn_do_sweep': lambda: measurement.bn_do_sweep(vip), '_bn_stop': lambda: se.bn_block_measurement(vip) } vip.content['cb_vals'][tb] = { 'B_is_max_1': ('ON', 'OFF'), 'B_is_max_2': ('ON', 'OFF'), 'B_is_max_3': ('ON', 'OFF'), 'B_find_min': ('ON', 'OFF') } vip.content['dm_vals'][tb] = { 'sweep_title_1': session.Tree['_Sweeps']['Sweep_1'].keys(), 'sweep_title_2': session.Tree['_Sweeps']['Sweep_2'].keys(), 'sweep_title_3': session.Tree['_Sweeps']['Sweep_3'].keys() } sw.__fill_widgets(vip, tb, fontsize=cs.FONTSIZE + 1) #### ---------- for k in ['_bn_do_sweep']: vip._qWidgets['bn'][tb][k].setFont( QtGui.QFont(cs.FONT, cs.FONTSIZE + 4)) vip._qWidgets['bn'][tb][k].adjustSize() for k in ['_bn_stop']: vip._qWidgets['bn'][tb][k].setFont( QtGui.QFont(cs.FONT, cs.FONTSIZE + 2)) vip._qWidgets['bn'][tb][k].adjustSize() for k in vip.content['captions'][tb]['cb'].keys(): vip._qWidgets['cb'][tb][k].setFixedWidth(200) vip._qWidgets['cb'][tb][k].setFont( QtGui.QFont(cs.FONT, cs.FONTSIZE + 1)) ########## ########## hBoxs _RANGE3 = ['1', '2', '3'] hBoxs = {k: QtGui.QHBoxLayout() for k in ['S', 'P'] + _RANGE3} hBoxs['_B_find_min'] = QtGui.QHBoxLayout() hBoxs['S'].addStretch(1) hBoxs['S'].addWidget(vip._qWidgets['bn'][tb]['_bn_do_sweep']) hBoxs['S'].addWidget(vip._qWidgets['bn'][tb]['_bn_stop']) hBoxs['S'].addStretch(1) hBoxs['_B_find_min'].addWidget(vip._qWidgets['cb'][tb]['B_find_min']) hBoxs['_B_find_min'].addStretch(1) hBoxs['P'].addStretch(1) hBoxs['P'].addWidget(vip._qWidgets['qw']['Meas_main']) ### hBoxs['P'].addStretch(1) for i in _RANGE3: hBoxs[i].addStretch(1) hBoxs[i].addWidget(vip._qWidgets['cb'][tb]['B_is_max_' + i]) hBoxs[i].addWidget(vip._qWidgets['dm'][tb]['sweep_title_' + i]) hBoxs[i].addStretch(1) ########## ########## vBox vBox = QtGui.QVBoxLayout(vip._qWidgets['qw'][tb]) vBox.addLayout(hBoxs['S']) vBox.addLayout(hBoxs['_B_find_min']) vBox.addLayout(vip._blanks.next()) vBox.addLayout(hBoxs['P']) vBox.addLayout(vip._blanks.next()) vBox.addLayout(hBoxs['1']) vBox.addLayout(vip._blanks.next()) vBox.addLayout(vip._blanks.next()) vBox.addLayout(vip._blanks.next()) vBox.addLayout(hBoxs['2']) vBox.addLayout(hBoxs['3'])
def _build_Script(vip): tb = 'Script' import dictionaries.script_dict as script_dict vip.content['captions'][tb]['lb'] = {} vip.content['captions'][tb]['bn'] = { '_bn_run_script': " Run script 3 now " } vip.content['captions'][tb]['cb'] = { 'B_during_sweep_1': "Add to sweep 1", 'B_during_sweep_2': "Add to sweep 2", 'B_during_sweep_3': "Add to sweep 3" } vip.content['events'][tb]['le'] = {} vip.content['events'][tb]['cb'] = { 'B_during_sweep_1': lambda state: se.cb_toggled(vip, tb, 'B_during_sweep_1'), 'B_during_sweep_2': lambda state: se.cb_toggled(vip, tb, 'B_during_sweep_2'), 'B_during_sweep_3': lambda state: se.cb_toggled(vip, tb, 'B_during_sweep_3') } vip.content['events'][tb]['dm'] = { 'script_title_1': lambda text: se.le_or_dm_change(vip, tb, 'script_title_1', text), 'script_title_2': lambda text: se.le_or_dm_change(vip, tb, 'script_title_2', text), 'script_title_3': lambda text: se.le_or_dm_change(vip, tb, 'script_title_3', text) } vip.content['events'][tb]['bn'] = { '_bn_run_script': lambda: se.bn_run_script(vip, '3') } vip.content['cb_vals'][tb] = { 'B_during_sweep_1': ('ON', 'OFF'), 'B_during_sweep_2': ('ON', 'OFF'), 'B_during_sweep_3': ('ON', 'OFF') } vip.content['dm_vals'][tb] = { 'script_title_1': script_dict.script_dictionary.keys(), 'script_title_2': script_dict.script_dictionary.keys(), 'script_title_3': script_dict.script_dictionary.keys() } sw.__fill_widgets(vip, tb) #### ---------- for k in ['_bn_run_script']: vip._qWidgets['bn'][tb][k].setFont( QtGui.QFont(cs.FONT, cs.FONTSIZE + 2)) vip._qWidgets['bn'][tb][k].adjustSize() for k in vip.content['captions'][tb]['cb'].keys(): vip._qWidgets['cb'][tb][k].setFont( QtGui.QFont(cs.FONT, cs.FONTSIZE + 1)) ########## ########## hBoxs _string_range_3 = [str(i) for i in range(1, 4)] hBox = {i: QtGui.QHBoxLayout() for i in _string_range_3 + ["__run"]} for i in _string_range_3: hBox[i].addWidget(vip._qWidgets['dm'][tb]['script_title_' + i]) hBox[i].addWidget(vip._qWidgets['cb'][tb]['B_during_sweep_' + i]) hBox["__run"].addStretch(1) hBox["__run"].addWidget(vip._qWidgets['bn'][tb]['_bn_run_script']) hBox["__run"].addStretch(1) ########## ########## vBox vBox = QtGui.QVBoxLayout(vip._qWidgets['qw'][tb]) for i in _string_range_3: vBox.addLayout(hBox[i]) vBox.addLayout(vip._blanks.next()) vBox.addLayout(hBox['__run']) vBox.addLayout(vip._blanks.next())
def _build_AWG_sweep(vip, tb): ### the values associated with the keywords with __ are not writen to the instrument tabs ### (only sweeped over in the measurement) ### Note: At the moment, H3344 is the only AWG and it has 4 channels (indexed by 0,1,2,3), ### and so is the range implemented here. In case there comes a AWG with more channels, ### a few things must be adjusted here. ### Also, if there are different AWGs with different numbers of channels, that might make things unsafe. from dictionaries.hardware import range_H3344_channels as channels_list sweep_quadruple = [ 'R__start', 'R__stop', 'N__sweep_points', 'R_AUXI_volt_step_size' ] vip.content['captions'][tb]['lb'] = { 'R__start': "Start voltage:" + 3 * cs.BLANK, 'R__stop': "Stop voltage:" + 4 * cs.BLANK, 'N__sweep_points': "Sweep points:" + 3 * cs.BLANK, '_lb_volt_step_size': "Step size:" + 12 * cs.BLANK, 'R_AUXI_volt_step_size': "init", 'USE_channel_': "Apply to", 'F__sweep_type': "Sweep" } vip.content['captions'][tb]['bn'] = {} vip.content['captions'][tb]['cb'] = { 'USE_channel_' + ch: ch for ch in channels_list } vip.content['events'][tb]['le'] = { 'R__start': lambda text: se.le_sweep_quadruple(vip, tb, sweep_quadruple, 'R__start', text), 'R__stop': lambda text: se.le_sweep_quadruple(vip, tb, sweep_quadruple, 'R__stop', text), 'N__sweep_points': lambda text: se.le_sweep_quadruple(vip, tb, sweep_quadruple, 'N__sweep_points', text) } vip.content['events'][tb]['dm'] = { 'F__sweep_type': lambda text: se.le_or_dm_change(vip, tb, 'F__sweep_type', text) } vip.content['events'][tb]['bn'] = {} vip.content['events'][tb]['cb'] = { 'USE_channel_0': lambda state: se.cb_toggled(vip, tb, 'USE_channel_0'), 'USE_channel_1': lambda state: se.cb_toggled(vip, tb, 'USE_channel_1'), 'USE_channel_2': lambda state: se.cb_toggled(vip, tb, 'USE_channel_2'), 'USE_channel_3': lambda state: se.cb_toggled(vip, tb, 'USE_channel_3') } ### I'm not sure if the following shorter function assignment might not make problems: #vip.content['events'][tb]['cb'] = {'USE_channel_'+ch : lambda state: se.cb_toggled(vip, tb, 'USE_channel_'+ch) for ch in channels_list} vip.content['cb_vals'][tb] = { 'USE_channel_' + ch: ('USE', 'DONT_USE') for ch in channels_list } vip.content['dm_vals'][tb] = {'F__sweep_type': ['Amplitude', 'Offset']} sw.__fill_widgets(vip, tb, fontsize=cs.FONTSIZE - 1) ### ---------- se._fun_change_step_size_value_label(vip, tb, sweep_quadruple) vip._qWidgets['lb'][tb][sweep_quadruple[3]].setFont( QtGui.QFont(cs.FONT, cs.FONTSIZE)) ########## ########## hBoxs le_ks = ['R__start', 'R__stop', 'N__sweep_points'] hBoxs_ks = ['USE_channel_'] + ['F__sweep_type'] + ['__lb_volt_step_size' ] + le_ks hBoxs = {k: QtGui.QHBoxLayout() for k in hBoxs_ks} hBoxs['USE_channel_'].addWidget(vip._qWidgets['lb'][tb]['USE_channel_']) for ch in range(4): hBoxs['USE_channel_'].addWidget( vip._qWidgets['cb'][tb]['USE_channel_' + str(ch)]) hBoxs['F__sweep_type'].addWidget(vip._qWidgets['lb'][tb]['F__sweep_type']) hBoxs['F__sweep_type'].addWidget(vip._qWidgets['dm'][tb]['F__sweep_type']) for k in le_ks: hBoxs[k].addWidget(vip._qWidgets['lb'][tb][k]) hBoxs[k].addWidget(vip._qWidgets['le'][tb][k]) hBoxs['__lb_volt_step_size'].addWidget( vip._qWidgets['lb'][tb]['_lb_volt_step_size']) hBoxs['__lb_volt_step_size'].addWidget( vip._qWidgets['lb'][tb]['R_AUXI_volt_step_size']) hBoxs['__lb_volt_step_size'].addStretch(.1) ########## ########## vBox vBox = QtGui.QVBoxLayout(vip._qWidgets['qw'][tb]) vBox.addLayout(hBoxs['USE_channel_']) vBox.addLayout(hBoxs['F__sweep_type']) for k in le_ks: vBox.addLayout(hBoxs[k]) vBox.addLayout(hBoxs['__lb_volt_step_size']) vBox.addLayout(hBoxs['F__sweep_type'])
def _build_Results(vip): tb = 'Results' vip.content['captions'][tb]['lb'] = {'_lb_session_line' : "Results" ,'_lb_name_index' : "File name:" ,'_lb_result_blank' : "_" ,'_lb_cb_selection' : "Save:" } vip.content['captions'][tb]['bn'] = {'_bn_result_dir_browse' : "Browse" ,'_bn_save_switch' : "Save" ,'_bn_meas_dir_today' : "Today" } vip.content['captions'][tb]['cb'] = {'B_save_result' : "Data to file" ,'B_save_session' : "Session" ,'B_save_screenshot' : "Screenshot" } vip.content['events'][tb]['le'] = {'DIR_PATH_results' : lambda text: se.le_or_dm_change(vip, tb,'DIR_PATH_results', text) ,'TITLE_result' : lambda text: se.le_or_dm_change(vip, tb,'TITLE_result' , text) ,'N_result_index' : lambda text: se.le_or_dm_change(vip, tb,'N_result_index', text) } vip.content['events'][tb]['dm'] = {} import interface.auxiliary_functions as auxi vip.content['events'][tb]['bn'] = {'_bn_result_dir_browse' : lambda: se.bn_browse_for(vip, 'DIR_PATH_results') ,'_bn_save_switch' : lambda: se.bn_save_switch(vip, auxi.textfile_formatting) ,'_bn_meas_dir_today' : lambda: se.bn_meas_dir_today(vip) } vip.content['events'][tb]['cb'] = {'B_save_result' : lambda state: se.cb_toggled(vip, tb,'B_save_result') ,'B_save_session' : lambda state: se.cb_toggled(vip, tb,'B_save_session') ,'B_save_screenshot' : lambda state: se.cb_toggled(vip, tb,'B_save_screenshot') } vip.content['cb_vals'][tb] = {'B_save_result' : ('ON', 'OFF') ,'B_save_session' : ('ON', 'OFF') ,'B_save_screenshot' : ('ON', 'OFF') } sw.__fill_widgets(vip, tb) ### ---------- vip._qWidgets['lb'][tb]['_lb_session_line'].setAlignment(QtCore.Qt.AlignCenter) vip._qWidgets['le'][tb]['N_result_index'].setFixedWidth(50) ########## ########## hBoxs hBox_ks = ['_cbs', '_browse', '_save', '_dir', '_file_name'] hBoxs = {k : QtGui.QHBoxLayout() for k in hBox_ks} hBoxs['_cbs'].addWidget(vip._qWidgets['lb'][tb]['_lb_cb_selection']) hBoxs['_cbs'].addLayout(vip._blanks.next()) hBoxs['_cbs'].addWidget(vip._qWidgets['cb'][tb]['B_save_result']) hBoxs['_cbs'].addLayout(vip._blanks.next()) hBoxs['_cbs'].addWidget(vip._qWidgets['cb'][tb]['B_save_session']) hBoxs['_cbs'].addLayout(vip._blanks.next()) hBoxs['_cbs'].addWidget(vip._qWidgets['cb'][tb]['B_save_screenshot']) hBoxs['_browse'].addWidget(vip._qWidgets['lb'][tb]['_lb_session_line']) hBoxs['_browse'].addWidget(vip._qWidgets['bn'][tb]['_bn_result_dir_browse']) hBoxs['_save'].addWidget(vip._qWidgets['bn'][tb]['_bn_save_switch']) hBoxs['_save'].addWidget(vip._qWidgets['bn'][tb]['_bn_meas_dir_today']) hBoxs['_dir'].addWidget(vip._qWidgets['le'][tb]['DIR_PATH_results']) hBoxs['_file_name'].addWidget(vip._qWidgets['lb'][tb]['_lb_name_index']) hBoxs['_file_name'].addStretch(.1) hBoxs['_file_name'].addWidget(vip._qWidgets['le'][tb]['TITLE_result']) hBoxs['_file_name'].addWidget(vip._qWidgets['lb'][tb]['_lb_result_blank']) hBoxs['_file_name'].addWidget(vip._qWidgets['le'][tb]['N_result_index']) ########## ########## vBox vBox = QtGui.QVBoxLayout(vip._qWidgets['qw'][tb]) for k in hBox_ks: vBox.addLayout(hBoxs[k])