我要告诉每一行它的背景和前景色是根据其年龄而定的。
输入
for i in range(0, 9999):
if i == i:
z = i + 2
z = z + float(0.20)
z = str(z) + "0"
a = i + 2
a = a + float(0.36)
if past_list[i] >= 60 * 60 * 24 * 56: # 56 days
txt1.tag_add("red_line0", z, a)
elif past_list[i] >= 60 * 60 * 24 * 28: # 28 days
txt1.tag_add("red4000_line0", z, a)
elif past_list[i] >= 60 * 60 * 24 * 14: # 14 days
txt1.tag_add("orange_line0", z, a)
elif past_list[i] >= 60 * 60 * 24 * 7: # 7 days
txt1.tag_add("orange_yellow_line0", z, a)
elif past_list[i] >= 60 * 60 * 24 * 5: # 5 days
txt1.tag_add("yellow_line0", z, a)
elif past_list[i] >= 60 * 60 * 24 * 1: # 1 day
txt1.tag_add("lime_line0", z, a)
elif past_list[i] >= 60 * 60 * 22: # 22 hours
txt1.tag_add("light_green_line0", z, a)
elif past_list[i] >= 60 * 60 * 2: # 2 hours
txt1.tag_add("neon_green_line0", z, a)
elif past_list[i] >= 0: # 0 hours
txt1.tag_add("blue_line0", z, a)
except IndexError:
pass
txt1.tag_config("blue_line0", background="black", foreground="#0000ff")
txt1.tag_config("neon_green_line0", background="black", foreground="#39ff14")
txt1.tag_config("light_green_line0", background="black", foreground="#90ee90")
txt1.tag_config("lime_line0", background="black", foreground="#bfff00")
txt1.tag_config("yellow_line0", background="black", foreground="#ffff00")
txt1.tag_config("orange_yellow_line0", background="black", foreground="#f8d568")
txt1.tag_config("orange_line0", background="black", foreground="#FFA500")
txt1.tag_config("red4000_line0", background="black", foreground="#FF4000")
txt1.tag_config("red_line0", background="black", foreground="#FF0000")
它会正确显示所有内容,一个很新的东西是蓝色,然后变成绿色,依此类推。 我只是想知道是否有一种方法可以使它更有效,例如,如果某事物在0秒时被指定为蓝色,而在60秒时被指定为绿色,那么在30秒标记处它可以显示一半绿色一半蓝色吗?仅仅是因为随着秒的滴答,它从蓝色过渡到绿色。 希望有道理。