这里有一个实现,允许您将六边形单元格设置为所需的颜色,并允许创建自定义边框颜色.
这是全部手工制作,只需使用您的参考站点1小时.您可能必须根据自己的需要进行调整,但似乎有效.
from tkinter import *
class HexaCanvas(Canvas):
""" A canvas that provides a create-hexagone method """
def __init__(self, master, *args, **kwargs):
Canvas.__init__(self, master, *args, **kwargs)
self.hexaSize = 20
def setHexaSize(self, number):
self.hexaSize = number
def create_hexagone(self, x, y, color = "black", fill="blue", color1=None, color2=None, color3=None, color4=None, color5=None, color6=None):
"""
Compute coordinates of 6 points relative to a center position.
Point are numbered following this schema :
Points in euclidiean grid:
6
5 1
.
4 2
3
Each color is applied to the side that link