# Draw Arrow with Pixels import tkinter as tk from PIL import Image, ImageTk import math w = 400 h = 400 root = tk.Tk() root.wm_title("Image Window") new_image = Image.new('RGB', (w, h)) image_data = [] for i in range(h): num_of_pixels = i*2 +1 num_of_pixels = math.ceil(num_of_pixels) if num_of_pixels > w: num_of_pixels = 100 start_index = (w - num_of_pixels)/2 start_index = math.ceil(start_index) print(num_of_pixels) for j in range(w): # if j < 100 or (100<=j <=300 and 150 300): if start_index <= j <= start_index + num_of_pixels -1: color_pixel = (0,255,100) else: color_pixel = (255,255,255) image_data.append(color_pixel) #Places RGB matrix into an image object called 'processed image' and saves to same directory as 'new_image.png' new_image.putdata(image_data) new_image.save('new_image.png') processed_image = ImageTk.PhotoImage(new_image) #Set width and height of canvas so that the image size is the same h = processed_image.height() w = processed_image.width() root.geometry(f"{w}x{h}") #Displays image in new window canvas = tk.Canvas(root,width=w,height=h) canvas.pack() canvas.create_image(0,0, anchor="nw", image=processed_image) root.mainloop()