У меня есть al oop, как показано ниже, для чтения значений напряжения для различных устройств.
for dut in range(TEST_BENCH_CURRENT_NB_DUTS):
if dut_sn[dut].get() == "" :
for voltage_test in range(Initial_voltages):
# Delay between voltage readings
try:
# Read DUT Voltage
time.sleep(1)
voltage = swapBits(busI2C.read_word_data(*I2C_ADDRESSES_1[voltage_test])) >> 4
voltage_readings[dut][voltage_test].set(str(voltage))
window.update()
time.sleep(0.1)
except:
voltage = 0
text = voltage_readings[dut][voltage_test].set(VOLTAGE_READ_PB)
window.update()
minimum_value = float(LIST_TP_VOLTAGE_MIN[voltage_test][7:])
maximum_value = float(LIST_TP_VOLTAGE_MAX[voltage_test][7:])
# Control value is min < value < max
if voltage < minimum_value or maximum_value < voltage :
#label_DUT1_Global_OK_KO_Status = Entry(window, textvariable=voltage_readings[dut][voltage_test], font=(None,TEXT_SIZE), highlightbackground ='red', state=DISABLED, justify=CENTER, width=ENTRY_WIDTH)
А еще у меня есть GUI, построенный с tkinter для отображения этих значений.
voltage_readings = []
for dut in range(NUM_DUT):
voltage_readings.append([])
for voltage_test in range(Initial_voltages):
voltage_readings[dut].append(StringVar())
label_DUT1_Voltage_Readings_01 = Entry(window, textvariable=voltage_readings[1 - 1][1 - 1], font=(None,TEXT_SIZE), disabledbackground ="#f7f5f5", disabledforeground ="black", state=DISABLED, justify=CENTER, width=ENTRY_WIDTH).place(x=X_LABEL_DUT1-X_LABEL_KEY_PADDING,y=Y_LABEL_FIRST+LIST_SCREEN_ORDER[2]*Y_LABEL_SPACE)
label_DUT2_Voltage_Readings_01 = Entry(window, textvariable=voltage_readings[2 - 1][1 - 1], font=(None,TEXT_SIZE), disabledbackground ="#f7f5f5", disabledforeground ="black", state=DISABLED, justify=CENTER, width=ENTRY_WIDTH).place(x=X_LABEL_DUT2-X_LABEL_KEY_PADDING,y=Y_LABEL_FIRST+LIST_SCREEN_ORDER[2]*Y_LABEL_SPACE)
label_DUT3_Voltage_Readings_01 = Entry(window, textvariable=voltage_readings[3 - 1][1 - 1], font=(None,TEXT_SIZE), disabledbackground ="#f7f5f5", disabledforeground ="black", state=DISABLED, justify=CENTER, width=ENTRY_WIDTH).place(x=X_LABEL_DUT3-X_LABEL_KEY_PADDING,y=Y_LABEL_FIRST+LIST_SCREEN_ORDER[2]*Y_LABEL_SPACE)
label_DUT4_Voltage_Readings_01 = Entry(window, textvariable=voltage_readings[4 - 1][1 - 1], font=(None,TEXT_SIZE), disabledbackground ="#f7f5f5", disabledforeground ="black", state=DISABLED, justify=CENTER, width=ENTRY_WIDTH).place(x=X_LABEL_DUT4-X_LABEL_KEY_PADDING,y=Y_LABEL_FIRST+LIST_SCREEN_ORDER[2]*Y_LABEL_SPACE)
label_DUT1_Voltage_Readings_02 = Entry(window, textvariable=voltage_readings[1 - 1][2 - 1], font=(None,TEXT_SIZE), disabledbackground ="#f7f5f5", disabledforeground ="black", state=DISABLED, justify=CENTER, width=ENTRY_WIDTH).place(x=X_LABEL_DUT1-X_LABEL_KEY_PADDING,y=Y_LABEL_FIRST+LIST_SCREEN_ORDER[3]*Y_LABEL_SPACE)
label_DUT2_Voltage_Readings_02 = Entry(window, textvariable=voltage_readings[2 - 1][2 - 1], font=(None,TEXT_SIZE), disabledbackground ="#f7f5f5", disabledforeground ="black", state=DISABLED, justify=CENTER, width=ENTRY_WIDTH).place(x=X_LABEL_DUT2-X_LABEL_KEY_PADDING,y=Y_LABEL_FIRST+LIST_SCREEN_ORDER[3]*Y_LABEL_SPACE)
label_DUT3_Voltage_Readings_02 = Entry(window, textvariable=voltage_readings[3 - 1][2 - 1], font=(None,TEXT_SIZE), disabledbackground ="#f7f5f5", disabledforeground ="black", state=DISABLED, justify=CENTER, width=ENTRY_WIDTH).place(x=X_LABEL_DUT3-X_LABEL_KEY_PADDING,y=Y_LABEL_FIRST+LIST_SCREEN_ORDER[3]*Y_LABEL_SPACE)
label_DUT4_Voltage_Readings_02 = Entry(window, textvariable=voltage_readings[4 - 1][2 - 1], font=(None,TEXT_SIZE), disabledbackground ="#f7f5f5", disabledforeground ="black", state=DISABLED, justify=CENTER, width=ENTRY_WIDTH).place(x=X_LABEL_DUT4-X_LABEL_KEY_PADDING,y=Y_LABEL_FIRST+LIST_SCREEN_ORDER[3]*Y_LABEL_SPACE)
label_DUT1_Voltage_Readings_03 = Entry(window, textvariable=voltage_readings[1 - 1][3 - 1], font=(None,TEXT_SIZE), disabledbackground ="#f7f5f5", disabledforeground ="black", state=DISABLED, justify=CENTER, width=ENTRY_WIDTH).place(x=X_LABEL_DUT1-X_LABEL_KEY_PADDING,y=Y_LABEL_FIRST+LIST_SCREEN_ORDER[4]*Y_LABEL_SPACE)
label_DUT2_Voltage_Readings_03 = Entry(window, textvariable=voltage_readings[2 - 1][3 - 1], font=(None,TEXT_SIZE), disabledbackground ="#f7f5f5", disabledforeground ="black", state=DISABLED, justify=CENTER, width=ENTRY_WIDTH).place(x=X_LABEL_DUT2-X_LABEL_KEY_PADDING,y=Y_LABEL_FIRST+LIST_SCREEN_ORDER[4]*Y_LABEL_SPACE)
label_DUT3_Voltage_Readings_03 = Entry(window, textvariable=voltage_readings[3 - 1][3 - 1], font=(None,TEXT_SIZE), disabledbackground ="#f7f5f5", disabledforeground ="black", state=DISABLED, justify=CENTER, width=ENTRY_WIDTH).place(x=X_LABEL_DUT3-X_LABEL_KEY_PADDING,y=Y_LABEL_FIRST+LIST_SCREEN_ORDER[4]*Y_LABEL_SPACE)
label_DUT4_Voltage_Readings_03 = Entry(window, textvariable=voltage_readings[4 - 1][3 - 1], font=(None,TEXT_SIZE), disabledbackground ="#f7f5f5", disabledforeground ="black", state=DISABLED, justify=CENTER, width=ENTRY_WIDTH).place(x=X_LABEL_DUT4-X_LABEL_KEY_PADDING,y=Y_LABEL_FIRST+LIST_SCREEN_ORDER[4]*Y_LABEL_SPACE)
Итак, моя проблема в том, что когда значение напряжения выходит за допустимые пределы, мне нужно выделить конкретную метку красным цветом. Может ли кто-нибудь помочь мне, как l oop эти переменные ярлыка, чтобы сделать это. Заранее спасибо!