def showLegend(): legendWd = Tk() # 2d legend object l_size = w_photo/4 legend = Canvas(legendWd, width = l_size, height = l_size) legend.grid(row = row_colorscheme, column = col_colorscheme, rowspan = h_span_colorscheme, columnspan = w_span_colorscheme) x = cr.createColorScheme(legendWd, category, row_colorscheme, col_colorscheme, s_colorcell, "quantile", "energy recovery") (color_2d, coloridDict) = x colorGrid = cr.colorRamp_2d(category, [255, 255, 255], [255, 0, 0], [0, 0, 255]) size = s_colorcell for i in range(category): for j in range(category): f = color_2d[i][j] f.create_rectangle(0, 0, size, size, fill = colorGrid[i][j], outline = defaultbg) # tick mark in 2d color ramp idx = allyear.get() for key in coloridDict: (h, c) = coloridDict[key][idx] g = color_2d[c][h] g.create_rectangle(0, 0, size, size, fill = colorGrid[c][h], outline = defaultbg) g.create_text(size/2, size/2, fill = font_color, font = bd_font, text = "x") legendWd.mainloop()
allyear.set(0) allyear.grid(row=row_year, column=col_year, rowspan=h_span_year, columnspan=w_span_year) # cover the original label monthTick = Canvas(master, width=w_slider, height=15) monthTick.grid(row=row_year, column=col_year, rowspan=h_span_year, columnspan=w_span_year, sticky=S) monthList = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] for i in range(12): monthTick.create_line(1 + w_slider / 12 * i, 1, 1 + w_slider / 12 * i, 8, fill=font_color) monthTick.create_text(26 + w_slider / 12 * i, 7, text=monthList[i], font=nm_font, fill=font_color) # 2d legend object l_size = w_photo / 4 legend = Canvas(master, width=l_size, height=l_size) legend.grid(row=row_colorscheme, column=col_colorscheme, rowspan=h_span_colorscheme, columnspan=w_span_colorscheme) x = cr.createColorScheme(master, category, row_colorscheme, col_colorscheme, s_colorcell, "quantile") (color_2d, coloridDict) = x colorGrid = cr.colorRamp_2d(category, [255, 255, 255], [255, 0, 0], [0, 0, 255]) # check button is3d = IntVar() ck3d = Checkbutton(master, width=4, text="3d", variable=is3d, onvalue=1, offvalue=0) ck3d.grid(row=row_button_0, column=col_button_0 + len(buttonList)) """ # clear selected landuse for calculation def clearSelect(): landSelection = [] hmap.g.delete("a") clearButton = Button(master, width = 5, text = 'clear', command = clearSelect)