•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Python section within the Software Development category of DaniWeb, a massive community of 427,097 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,317 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Python advertiser: Programming Forums
Views: 391 | Replies: 1
![]() |
•
•
Join Date: Jun 2008
Location: Milano, Italy
Posts: 16
Reputation:
Rep Power: 1
Solved Threads: 2
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 http://www.pythonware.com/products/pil/
Then a very simple example which focus only on the load image and canvas part:
I hope this can be of help.
You can refer also to these guides
http://www.pythonware.com/library/tkinter/introduction/
http://infohost.nmt.edu/tcc/help/pubs/tkinter/
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?
Gab
So I advise you first to install PIL from here http://www.pythonware.com/products/pil/
Then a very simple example which focus only on the load image and canvas part:
python Syntax (Toggle Plain Text)
#here you import the module from PIL import Image, ImageTk #here you load the image you are going to use Logo_IMG = Image.open("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) Canv_logo.grid() #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
http://www.pythonware.com/library/tkinter/introduction/
http://infohost.nmt.edu/tcc/help/pubs/tkinter/
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?
Gab
![]() |
•
•
•
•
•
•
•
•
DaniWeb Python Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Projects for the Beginner (Python)
- Starting Python (Python)
- Tkinter or wxPython? (Python)
- Tkinter Button(s) (Python)
- Tkinter, GUI's, Logic... (Python)
- Python - Card Class - Graphics Win (Python)
Other Threads in the Python Forum
- Previous Thread: psycopg2: database connectivity to PostgreSQL
- Next Thread: linux


Linear Mode