我正在编写一个绘图程序,我试图做出一个选择,改变画布背景颜色,但由于某些原因,它不起作用。没有错误信息,我不知道为什么它不起作用,因为我用了几乎相同的代码来改变线的颜色。在
另外,我对python很陌生。在
代码:from tkinter import *
# canvas specifications/variables
canvas_height = 400
canvas_width = 600
p1_canvas_colour = "white"
p1_canvas_colour_number = 1
#p1 (what you draw with) specifications/variables
p1_x = canvas_width/2
p1_y = canvas_height
p1_colour = "black"
p1_colour_change = 1
line_width = 1
line_length = 1
#p1 controls
def p1_move_N(event):
global p1_y
canvas.create_line(p1_x, p1_y, p1_x, (p1_y-line_length), width=line_width, fill=p1_colour)
p1_y = p1_y - line_length
def p1_move_S(event):
global p1_y
canvas.create_line(p1_x, p1_y, p1_x, (p1_y+line_length), width=line_w