I am trying to create place a gif onto my tkinter canvas, however it is just a still image when it is placed.
Does anyone know how I could maybe place it but it moves when the code runs?
On my canvas, I am creating a large number of objects and images, and once loaded, the program finds it hard to maintain this large quantity and frequently crashes. A solution I thought up would be to convert the canvas into an image (perhaps using PIL?), clear the canvas and use canvas.create_image to paste the image-form of the original canvas. I am aware, and have found in similar questions, there are ways to convert the image to a png file/save the file on the PC - I do not want this - I want to turn the image into a PIL image or tkinter PhotoImage.
How can I go about doing this?
Thanks
After looking for answers all around, I find lots of help and guidance on how to save a file either using turtle screen or tkinter canvas mixed with the turtle module. I'm drawing a large image and the windows size is fine and scrollable, letting me see the entire image. But when I try to save the image to postscript, I only get the window view, not the entire canvas. Cannot find out how to proceed, any tips?
There might be an answer in How can I convert canvas content to an image? but I cannot see how to connect tkinter with turtle. Can someone elaborate on that?
I have an issue with the Tkinter Canvas, saving it to an image, but more importantly, getting a specific pixel of the Tkinter Canvas. All I need is for that specific X, Y coordinate, I want its color value. By 'color value', any value I can use to draw a pixel with the python imaging library would work.
Here's what I tried to do to make it work:
I first tried to use python imaging library's image grabbing class to get the Canvas Image, but that didn't work as expected.
I then tried to convert the Tkinter Canvas to an image by with the "eps" file, but that didn't work, and GhostScript didn't work either.
Next, I searched to see if there was any way to get the pixel at a certain coordinate on a Tkinter canvas to no avail. That's where I posted this.
Next, here's the code I tried for step 2:
screen = w
#staticmethod
def image():
w.postscript(file=".canvas_script.eps")
img = Image.open(".canvas_script.eps")
return img
# GhostScript Error
Expected Result: My expected result is to get the color of any certain point, or at least to get a color of the point that I can convert to another color tuple or value. Then, to put draw that on a python imaging library image.
Actual Result: I found no method on the internet when I researched that solved my question, and no method in the documentation.
If anyone can help me get the color from a specific coordinate of the Tkinter Canvas, say (0, 0), please do. Thanks!
How do I get specific pixels of the tkinter canvas?
You can't. The canvas isn't a pixel oriented widget. The best you can do is use some other library to create a screenshot of the canvas, and then use the image to give you the values that you want.
I have a small image file that I would like to make as the tiled background image on a tkinter canvas in Python 3.4. I want the image to repeat indefinitely even if the canvas window is resized. How can I go about implementing this?
Looking around on the internet leads me to believe that there isn't any native tkinter feature for doing this simply. Is there any "black-box" method in an image library that can interface with tkinter for doing this tiling? Or should I manually render copies of the image at regularly spaced coordinates?