GDI+ - 对形状的引用
GDI+ - References to Shapes
在 python 中,当使用 tkinter
模块绘图时,您可以保留对形状的引用,然后使用该引用操作该形状。
在使用 GDI+ 的 .NET 中是否有类似的东西?有哪些解决方法?
from tkinter import *
tk = Tk()
canvas = Canvas(tk, width=500, height=500)
canvas.pack()
id = canvas.create_polygon(10, 10, 30, 60, 60, 10, fill='blue') # returns reference
count = 0
def movetriangle(event):
canvas.move(id, 5, 3)
global count
if count == 0:
canvas.itemconfig(id, fill='red')
count = 1
elif count == 1:
canvas.itemconfig(id, fill='green')
count = 2
else:
canvas.itemconfig(id, fill='blue')
count = 0
canvas.bind_all('<KeyPress-Return>', movetriangle)
在 python 中,当使用 tkinter
模块绘图时,您可以保留对形状的引用,然后使用该引用操作该形状。
在使用 GDI+ 的 .NET 中是否有类似的东西?有哪些解决方法?
from tkinter import *
tk = Tk()
canvas = Canvas(tk, width=500, height=500)
canvas.pack()
id = canvas.create_polygon(10, 10, 30, 60, 60, 10, fill='blue') # returns reference
count = 0
def movetriangle(event):
canvas.move(id, 5, 3)
global count
if count == 0:
canvas.itemconfig(id, fill='red')
count = 1
elif count == 1:
canvas.itemconfig(id, fill='green')
count = 2
else:
canvas.itemconfig(id, fill='blue')
count = 0
canvas.bind_all('<KeyPress-Return>', movetriangle)