Can anyone help me in graphics in python GUI using Tkinter toolkit...can anyone give me a code that can implement simple images onto the canvas of a GUI program, i know i have to use bmp. or gif. images which is fine because i got that.


I use PIL (Python Imaging Library) module which is more flexible with graphics usage in python and let you use formats different from say gif.
So I advise you first to install PIL from here
Then a very simple example which focus only on the load image and canvas part:

#here you import the module
from PIL import Image, ImageTk
#here you load the image you are going to use
Logo_IMG ="C:\Python25\..........\Logo.png")
#here you use Photoimage to assign the image to ImageTk
Logo_TK = ImageTk.PhotoImage(Logo_IMG)
#here you create a simple canvas widget -I assume you have already a frame to put it
Canv_logo = Canvas(your_canvas_frame, width=50, height=50, bg="white", bd=0)
#here you show the image in the canvas
Canv_logo.create_image(36, 36, image=Logo_TK)
#here you reference at the image again -without this you won't see the image-
Canv_logo.image = Logo_TK

I hope this can be of help.
You can refer also to these guides

By the way I've noticed that in windows the image is bordered by default Tk gray. Even if I try to set frame/widget bg and bd to white the gray border stays there and grey anyway... Any suggestion for solving this issue?


Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.