조작 광 화상 개체 :왜 Photoimage가 느린가? 와
import tkinter as tk
img = tk.PhotoImage(file="myFile.gif")
for x in range(0,1000):
for y in range(0,1000):
img.put("{red}", (x, y))
풋 조작은 매우 긴 시간이 걸립니다. 이 작업을 수행하는 더 빠른 방법이 있습니까?
조작 광 화상 개체 :왜 Photoimage가 느린가? 와
import tkinter as tk
img = tk.PhotoImage(file="myFile.gif")
for x in range(0,1000):
for y in range(0,1000):
img.put("{red}", (x, y))
풋 조작은 매우 긴 시간이 걸립니다. 이 작업을 수행하는 더 빠른 방법이 있습니까?
는 경계 상자를 사용
이from Tkinter import *
root = Tk()
label = Label(root)
label.pack()
img = PhotoImage(width=300,height=300)
data = ("{red red red red blue blue blue blue}")
img.put(data, to=(20,20,280,280))
label.config(image=img)
root.mainloop()
이 대답은 오래되었지만, "{적색 적색 적색 청색 파란색 파란색 파란색}" "을 데이터 입력으로 사용하여 색상 열을 만드는 방법을 설명 할 수 있습니까? –
감사합니다. 다른 사람이이 문제를 겪고 비슷한 질문을하면 [이 기사] (http://tkinter.unpythonic.net/wiki/PhotoImage)에서 잘 설명합니다. –
두 번째 색상 배열을 구성하고 해당 배열을 매개 변수로 사용하여 put
을 호출하십시오. 이처럼
:
import tkinter as tk
img = tk.PhotoImage(file="myFile.gif")
# "#%02x%02x%02x" % (255,0,0) means 'red'
line = '{' + ' '.join(["#%02x%02x%02x" % (255,0,0)] * 1000) + '}'
img.put(' '.join([line] * 1000))
noob oddy 답변이 더 효율적입니다. (그리고 더 명확하게) – FabienAndre
@FabienAndre 예, 그렇습니다. upvoted – soulcheck
나는 그것의 아마 단지'넣어()'그 속도가 느린 전화,하지만 당신은 사실하지 말 것 매우 느린 중첩 된 for 루프 (1000^2)를 수행합니다. 그러나 @ 넋 검사는 당신을위한 정답입니다. – jdi