cannot typecheck the program #618
Unanswered
datalittle
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I understand that my code is a mess but whenever I try to run it I get: error: cannot typecheck the program.
`from python import tkinter as tk
window = tk.Tk()
opened = list()
f= open('file.format','r')
opened = f.readlines()
met = opened.pop(0)
f.close()
window.title( "file reader")
height = len(opened)
width = int(met)
scale = int(1)
winwidth = width // scale
winheight = (height) // scale
canvas = tk.Canvas(window, width=winwidth, height=winheight, bg="#000000")
canvas.pack()
img = tk.PhotoImage(width=width, height=height)
y = height
threads = list()
def torgba(pixel):
splitpix = pixel.split(",")
r = int(splitpix[0])
g = int(splitpix[1])
b = int(splitpix[2])
a = int(splitpix[3])
return r,g,b,a
def paintpixel(r,g,b,x,y):
hex = f"#{r:02x}{g:02x}{b:02x}"
img.put(hex, (x, y))
y=1
for line in opened:
x=1
line =line.replace('[','')
line = line.replace('\n','')
splitline = line.split(']')
for item in splitline:
if item:
pixel = torgba(item)
paintpixel(pixel[0],pixel[1],pixel[2],x,y)
x +=1
y += 1
newimg = img.subsample(scale,scale)
canvas.create_image( winwidth//2, winheight//2, image=newimg)
window.update()
tk.mainloop()
`
Beta Was this translation helpful? Give feedback.
All reactions