我正在研究自动机理论,我被要求编写一个看起来或多或少的自动机的图形(树):
到目前为止,我得到了这个(我使用tkinter和canvas绘制):
from tkinter import Tk, Canvas, mainloop
def circle(canvas, x, y, r, width):
id = canvas.create_oval (x-r, y-r, x+r, y+r, width = width)
return id
def line (canvas, x1, y1, x2, y2, width):
canvas.create_line (x1, y1, x2, y2, width = width)
def text (canvas, x, y, text):
canvas.create_text (x, y, text = text, font = ("bold", 20))
w = Canvas(Tk (), width=1000, height=600, bg = "white")
circle (w , 150, 300, 70, 3)
circle (w , 150, 300, 50, 3)
circle (w , 370, 300, 70, 3)
circle (w , 640, 300, 70, 3)
circle (w , 910, 300, 70, 3)
line (w, 10, 300, 80, 300, 3)
circle (w, 73, 300, 5, 6)
line (w, 220, 300, 300, 300, 3)
circle (w, 293, 300, 5, 6)<