Trouble with using Tkinter images
up vote
0
down vote
favorite
The code below is supposed to lay out a map and have tag_bind buttons in certain areas. And when the buttons are clicked an icon is supposed to appear near the buttons. Problem is I can't apply more than one image. The image of the icon over the image of the map to be precise.
from tkinter import *
root = Tk()
def clicked(event):
print("pressed")
def birdYellow(event):
yellowbutton = canvas1.create_rectangle(50, 10, 100, 60, fill="yellow", outline="black")
gifbird = PhotoImage(file='bird.gif')
canvas1.create_image(50, 10, image=gifbird, anchor=NW)
Title = Label(root, text="Angry Bird Alert", bg="red", fg="white")
Title.pack()
canvas1 = Canvas(root, width=825, height=825, bg='black')
canvas1.pack(expand=YES, fill=BOTH)
gif1 = PhotoImage(file='Map1.gif')
canvas1.create_image(50, 10, image=gif1, anchor=NW)
buttonBG = canvas1.create_rectangle(160, 152, 260, 170, fill="yellow", outline="black")
buttonTXT = canvas1.create_text(210, 160, text="Yellow District")
canvas1.tag_bind(buttonBG, "<Button-1>", birdYellow)
canvas1.tag_bind(buttonTXT, "<Button-1>", birdYellow)
root.mainloop()
I've found other threads in this site discussing image over an image in tkinter but they all involved the PIL module. And anytime I use it, it says no module found. I have followed instructions on how to fix it but none seemed to work.
Is there any other possible technique to apply multiple images without using PIL?
Using Python 3.6.1 and pip 18.1
python tkinter pip python-imaging-library
add a comment |
up vote
0
down vote
favorite
The code below is supposed to lay out a map and have tag_bind buttons in certain areas. And when the buttons are clicked an icon is supposed to appear near the buttons. Problem is I can't apply more than one image. The image of the icon over the image of the map to be precise.
from tkinter import *
root = Tk()
def clicked(event):
print("pressed")
def birdYellow(event):
yellowbutton = canvas1.create_rectangle(50, 10, 100, 60, fill="yellow", outline="black")
gifbird = PhotoImage(file='bird.gif')
canvas1.create_image(50, 10, image=gifbird, anchor=NW)
Title = Label(root, text="Angry Bird Alert", bg="red", fg="white")
Title.pack()
canvas1 = Canvas(root, width=825, height=825, bg='black')
canvas1.pack(expand=YES, fill=BOTH)
gif1 = PhotoImage(file='Map1.gif')
canvas1.create_image(50, 10, image=gif1, anchor=NW)
buttonBG = canvas1.create_rectangle(160, 152, 260, 170, fill="yellow", outline="black")
buttonTXT = canvas1.create_text(210, 160, text="Yellow District")
canvas1.tag_bind(buttonBG, "<Button-1>", birdYellow)
canvas1.tag_bind(buttonTXT, "<Button-1>", birdYellow)
root.mainloop()
I've found other threads in this site discussing image over an image in tkinter but they all involved the PIL module. And anytime I use it, it says no module found. I have followed instructions on how to fix it but none seemed to work.
Is there any other possible technique to apply multiple images without using PIL?
Using Python 3.6.1 and pip 18.1
python tkinter pip python-imaging-library
Are you asking about the problems installing a module, or problems in displaying images? You shouldn't be asking two such wildly different questions at once.
– Bryan Oakley
Nov 7 at 20:13
It would be best if you could condense this question down to a Minimal, Complete, and Verifiable example. If the question is about an image over a canvas, I don't think we need 8 rectangles and 8 text items in addition to the canvas.
– Bryan Oakley
Nov 7 at 20:15
Yup, my bad Bryan. Edited.
– battery051
Nov 8 at 9:08
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
The code below is supposed to lay out a map and have tag_bind buttons in certain areas. And when the buttons are clicked an icon is supposed to appear near the buttons. Problem is I can't apply more than one image. The image of the icon over the image of the map to be precise.
from tkinter import *
root = Tk()
def clicked(event):
print("pressed")
def birdYellow(event):
yellowbutton = canvas1.create_rectangle(50, 10, 100, 60, fill="yellow", outline="black")
gifbird = PhotoImage(file='bird.gif')
canvas1.create_image(50, 10, image=gifbird, anchor=NW)
Title = Label(root, text="Angry Bird Alert", bg="red", fg="white")
Title.pack()
canvas1 = Canvas(root, width=825, height=825, bg='black')
canvas1.pack(expand=YES, fill=BOTH)
gif1 = PhotoImage(file='Map1.gif')
canvas1.create_image(50, 10, image=gif1, anchor=NW)
buttonBG = canvas1.create_rectangle(160, 152, 260, 170, fill="yellow", outline="black")
buttonTXT = canvas1.create_text(210, 160, text="Yellow District")
canvas1.tag_bind(buttonBG, "<Button-1>", birdYellow)
canvas1.tag_bind(buttonTXT, "<Button-1>", birdYellow)
root.mainloop()
I've found other threads in this site discussing image over an image in tkinter but they all involved the PIL module. And anytime I use it, it says no module found. I have followed instructions on how to fix it but none seemed to work.
Is there any other possible technique to apply multiple images without using PIL?
Using Python 3.6.1 and pip 18.1
python tkinter pip python-imaging-library
The code below is supposed to lay out a map and have tag_bind buttons in certain areas. And when the buttons are clicked an icon is supposed to appear near the buttons. Problem is I can't apply more than one image. The image of the icon over the image of the map to be precise.
from tkinter import *
root = Tk()
def clicked(event):
print("pressed")
def birdYellow(event):
yellowbutton = canvas1.create_rectangle(50, 10, 100, 60, fill="yellow", outline="black")
gifbird = PhotoImage(file='bird.gif')
canvas1.create_image(50, 10, image=gifbird, anchor=NW)
Title = Label(root, text="Angry Bird Alert", bg="red", fg="white")
Title.pack()
canvas1 = Canvas(root, width=825, height=825, bg='black')
canvas1.pack(expand=YES, fill=BOTH)
gif1 = PhotoImage(file='Map1.gif')
canvas1.create_image(50, 10, image=gif1, anchor=NW)
buttonBG = canvas1.create_rectangle(160, 152, 260, 170, fill="yellow", outline="black")
buttonTXT = canvas1.create_text(210, 160, text="Yellow District")
canvas1.tag_bind(buttonBG, "<Button-1>", birdYellow)
canvas1.tag_bind(buttonTXT, "<Button-1>", birdYellow)
root.mainloop()
I've found other threads in this site discussing image over an image in tkinter but they all involved the PIL module. And anytime I use it, it says no module found. I have followed instructions on how to fix it but none seemed to work.
Is there any other possible technique to apply multiple images without using PIL?
Using Python 3.6.1 and pip 18.1
python tkinter pip python-imaging-library
python tkinter pip python-imaging-library
edited Nov 8 at 9:15
asked Nov 7 at 15:44
battery051
11
11
Are you asking about the problems installing a module, or problems in displaying images? You shouldn't be asking two such wildly different questions at once.
– Bryan Oakley
Nov 7 at 20:13
It would be best if you could condense this question down to a Minimal, Complete, and Verifiable example. If the question is about an image over a canvas, I don't think we need 8 rectangles and 8 text items in addition to the canvas.
– Bryan Oakley
Nov 7 at 20:15
Yup, my bad Bryan. Edited.
– battery051
Nov 8 at 9:08
add a comment |
Are you asking about the problems installing a module, or problems in displaying images? You shouldn't be asking two such wildly different questions at once.
– Bryan Oakley
Nov 7 at 20:13
It would be best if you could condense this question down to a Minimal, Complete, and Verifiable example. If the question is about an image over a canvas, I don't think we need 8 rectangles and 8 text items in addition to the canvas.
– Bryan Oakley
Nov 7 at 20:15
Yup, my bad Bryan. Edited.
– battery051
Nov 8 at 9:08
Are you asking about the problems installing a module, or problems in displaying images? You shouldn't be asking two such wildly different questions at once.
– Bryan Oakley
Nov 7 at 20:13
Are you asking about the problems installing a module, or problems in displaying images? You shouldn't be asking two such wildly different questions at once.
– Bryan Oakley
Nov 7 at 20:13
It would be best if you could condense this question down to a Minimal, Complete, and Verifiable example. If the question is about an image over a canvas, I don't think we need 8 rectangles and 8 text items in addition to the canvas.
– Bryan Oakley
Nov 7 at 20:15
It would be best if you could condense this question down to a Minimal, Complete, and Verifiable example. If the question is about an image over a canvas, I don't think we need 8 rectangles and 8 text items in addition to the canvas.
– Bryan Oakley
Nov 7 at 20:15
Yup, my bad Bryan. Edited.
– battery051
Nov 8 at 9:08
Yup, my bad Bryan. Edited.
– battery051
Nov 8 at 9:08
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53192863%2ftrouble-with-using-tkinter-images%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Are you asking about the problems installing a module, or problems in displaying images? You shouldn't be asking two such wildly different questions at once.
– Bryan Oakley
Nov 7 at 20:13
It would be best if you could condense this question down to a Minimal, Complete, and Verifiable example. If the question is about an image over a canvas, I don't think we need 8 rectangles and 8 text items in addition to the canvas.
– Bryan Oakley
Nov 7 at 20:15
Yup, my bad Bryan. Edited.
– battery051
Nov 8 at 9:08