python六边形网格_使用Python在六边形网格中显示数据

这里有一个实现,允许您将六边形单元格设置为所需的颜色,并允许创建自定义边框颜色.

这是全部手工制作,只需使用您的参考站点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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值