Why is Photoimage put slow?

When manipulating photoimage objects, with:

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))

the put operation takes a very long time. Is there a faster method of doing this?

Answers


Use a bounding box:

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()

Need Your Help

Mysql Schema in Node.js?

javascript mysql node.js

I am developing a web service with Node.js,but I will work with mysql, I used to use mongoDB and I could create an Schema:

Swapping panels in a frame

java panel frame

So i have a frame and 2 panels, originally panel A is displayed in the frame. i have got it set up so when a button is clicked in the panel it makes a call back to the frame and runs this bit of co...