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










share|improve this question
























  • 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















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










share|improve this question
























  • 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













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










share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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


















  • 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

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















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






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














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





















































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







這個網誌中的熱門文章

Xamarin.form Move up view when keyboard appear

Post-Redirect-Get with Spring WebFlux and Thymeleaf

Anylogic : not able to use stopDelay()