Tkinter image on canvas wont update The Next CEO of Stack Overflowttk tkinter multiple frames/windowsHow to clear Tkinter Canvas?wxpython - Erase background erases non-background componentsTkinter canvas not updatingmoving and resize image canvas object in tkinterTkinter Canvas, Deletion of ImagesTkinter recursive behavior with '<Configure>' callbackUpdate Tkinter canvas in mainloop()Tkinter Canvas Text update: Text wont update on button pressIs there any way to resize button size in python tkinter?
Is it correct to say moon starry nights?
Point distance program written without a framework
IC has pull-down resistors on SMBus lines?
In the "Harry Potter and the Order of the Phoenix" video game, what potion is used to sabotage Umbridge's speakers?
How to avoid supervisors with prejudiced views?
Where do students learn to solve polynomial equations these days?
Is it okay to majorly distort historical facts while writing a fiction story?
Yu-Gi-Oh cards in Python 3
What flight has the highest ratio of timezone difference to flight time?
What difference does it make using sed with/without whitespaces?
Is fine stranded wire ok for main supply line?
Can I board the first leg of the flight without having final country's visa?
Man transported from Alternate World into ours by a Neutrino Detector
Is a distribution that is normal, but highly skewed, considered Gaussian?
Is there a way to save my career from absolute disaster?
Is it ok to trim down a tube patch?
Can this note be analyzed as a non-chord tone?
Traveling with my 5 year old daughter (as the father) without the mother from Germany to Mexico
Why do we say 'Un seul M' and not 'Une seule M' even though M is a "consonne"
Do I need to write [sic] when including a quotation with a number less than 10 that isn't written out?
Defamation due to breach of confidentiality
How do you define an element with an ID attribute using LWC?
"Eavesdropping" vs "Listen in on"
Could a dragon use its wings to swim?
Tkinter image on canvas wont update
The Next CEO of Stack Overflowttk tkinter multiple frames/windowsHow to clear Tkinter Canvas?wxpython - Erase background erases non-background componentsTkinter canvas not updatingmoving and resize image canvas object in tkinterTkinter Canvas, Deletion of ImagesTkinter recursive behavior with '<Configure>' callbackUpdate Tkinter canvas in mainloop()Tkinter Canvas Text update: Text wont update on button pressIs there any way to resize button size in python tkinter?
So this code is activated on button press and that part definitely works due to print updated..., however the picture doesn't change like it should, even if i comment out the resizing stuff....
the programming opens a window with an image on and a button, on button click in theory the image should change
any help would be humongous appreciated
def __init__(self,root):
self.pictures=Pictures()
self.photo = self.pictures.gif
image1=Image.open(self.pictures.gif)
(self.w,self.h)=image1.size
self.canvas = tk.Canvas(root, width=self.w, height=self.h)
self.canvas.grid(row=1, column=1)
self.canvas.image = ImageTk.PhotoImage(Image.open(self.photo))
self.item=self.canvas.create_image(0, 0, image=self.canvas.image, anchor="nw")
self.v = tk.StringVar()
textstring=textstrings()
self.canvas.create_text(300,0,fill="white",font="Times 10 italic bold",anchor='n',text=textstring.introduction)
self.btn1=tk.Button(root, width=15, height =1,textvariable=self.v,command=self.buttonclickstart)
self.btn1_window = self.canvas.create_window((self.w/2),(self.h/2)+3 ,anchor="center", window=self.btn1)
self.v.set("Play")
def change_pic(self):
self.pictures=Pictures()
self.image1=Image.open(self.pictures.pic2)
self.wpercent=self.w/float(self.image1.size[0])
self.hsize=(int(float(self.image1.size[1])*float(self.wpercent)))
self.image1=self.image1.resize((self.w,self.hsize),Image.ANTIALIAS)
self.image1.save(self.pictures.pic2)
self.canvas.image2 = ImageTk.PhotoImage(self.image1)
self.canvas.itemconfigure(self.item, image = self.canvas.image2 )
self.canvas.grid()
print ("updated")
def buttonclickstart(self):
self.btn1.destroy()
print ("updated1")
self.change_pic()
self.userinput()
python python-3.x tkinter tkinter-canvas
add a comment |
So this code is activated on button press and that part definitely works due to print updated..., however the picture doesn't change like it should, even if i comment out the resizing stuff....
the programming opens a window with an image on and a button, on button click in theory the image should change
any help would be humongous appreciated
def __init__(self,root):
self.pictures=Pictures()
self.photo = self.pictures.gif
image1=Image.open(self.pictures.gif)
(self.w,self.h)=image1.size
self.canvas = tk.Canvas(root, width=self.w, height=self.h)
self.canvas.grid(row=1, column=1)
self.canvas.image = ImageTk.PhotoImage(Image.open(self.photo))
self.item=self.canvas.create_image(0, 0, image=self.canvas.image, anchor="nw")
self.v = tk.StringVar()
textstring=textstrings()
self.canvas.create_text(300,0,fill="white",font="Times 10 italic bold",anchor='n',text=textstring.introduction)
self.btn1=tk.Button(root, width=15, height =1,textvariable=self.v,command=self.buttonclickstart)
self.btn1_window = self.canvas.create_window((self.w/2),(self.h/2)+3 ,anchor="center", window=self.btn1)
self.v.set("Play")
def change_pic(self):
self.pictures=Pictures()
self.image1=Image.open(self.pictures.pic2)
self.wpercent=self.w/float(self.image1.size[0])
self.hsize=(int(float(self.image1.size[1])*float(self.wpercent)))
self.image1=self.image1.resize((self.w,self.hsize),Image.ANTIALIAS)
self.image1.save(self.pictures.pic2)
self.canvas.image2 = ImageTk.PhotoImage(self.image1)
self.canvas.itemconfigure(self.item, image = self.canvas.image2 )
self.canvas.grid()
print ("updated")
def buttonclickstart(self):
self.btn1.destroy()
print ("updated1")
self.change_pic()
self.userinput()
python python-3.x tkinter tkinter-canvas
Have you verified thatchange_pic
is being called? Have you verified thatself.wpercent
andself.hsize
were properly computed? Have you verified that the image which was saved is what you expect?
– Bryan Oakley
Mar 7 at 18:48
Works for me, the image get updated. But i didn'tself.image1.save(...
– stovfl
Mar 7 at 19:18
Change pic is definitely being called as when it is called it prints "updated" which it does after every button press :) wpercent and hsize are correct too and the images are definitely name correctly and in the same folder as my program :) @BryanOakley
– Katie MAISON
Mar 7 at 20:17
add a comment |
So this code is activated on button press and that part definitely works due to print updated..., however the picture doesn't change like it should, even if i comment out the resizing stuff....
the programming opens a window with an image on and a button, on button click in theory the image should change
any help would be humongous appreciated
def __init__(self,root):
self.pictures=Pictures()
self.photo = self.pictures.gif
image1=Image.open(self.pictures.gif)
(self.w,self.h)=image1.size
self.canvas = tk.Canvas(root, width=self.w, height=self.h)
self.canvas.grid(row=1, column=1)
self.canvas.image = ImageTk.PhotoImage(Image.open(self.photo))
self.item=self.canvas.create_image(0, 0, image=self.canvas.image, anchor="nw")
self.v = tk.StringVar()
textstring=textstrings()
self.canvas.create_text(300,0,fill="white",font="Times 10 italic bold",anchor='n',text=textstring.introduction)
self.btn1=tk.Button(root, width=15, height =1,textvariable=self.v,command=self.buttonclickstart)
self.btn1_window = self.canvas.create_window((self.w/2),(self.h/2)+3 ,anchor="center", window=self.btn1)
self.v.set("Play")
def change_pic(self):
self.pictures=Pictures()
self.image1=Image.open(self.pictures.pic2)
self.wpercent=self.w/float(self.image1.size[0])
self.hsize=(int(float(self.image1.size[1])*float(self.wpercent)))
self.image1=self.image1.resize((self.w,self.hsize),Image.ANTIALIAS)
self.image1.save(self.pictures.pic2)
self.canvas.image2 = ImageTk.PhotoImage(self.image1)
self.canvas.itemconfigure(self.item, image = self.canvas.image2 )
self.canvas.grid()
print ("updated")
def buttonclickstart(self):
self.btn1.destroy()
print ("updated1")
self.change_pic()
self.userinput()
python python-3.x tkinter tkinter-canvas
So this code is activated on button press and that part definitely works due to print updated..., however the picture doesn't change like it should, even if i comment out the resizing stuff....
the programming opens a window with an image on and a button, on button click in theory the image should change
any help would be humongous appreciated
def __init__(self,root):
self.pictures=Pictures()
self.photo = self.pictures.gif
image1=Image.open(self.pictures.gif)
(self.w,self.h)=image1.size
self.canvas = tk.Canvas(root, width=self.w, height=self.h)
self.canvas.grid(row=1, column=1)
self.canvas.image = ImageTk.PhotoImage(Image.open(self.photo))
self.item=self.canvas.create_image(0, 0, image=self.canvas.image, anchor="nw")
self.v = tk.StringVar()
textstring=textstrings()
self.canvas.create_text(300,0,fill="white",font="Times 10 italic bold",anchor='n',text=textstring.introduction)
self.btn1=tk.Button(root, width=15, height =1,textvariable=self.v,command=self.buttonclickstart)
self.btn1_window = self.canvas.create_window((self.w/2),(self.h/2)+3 ,anchor="center", window=self.btn1)
self.v.set("Play")
def change_pic(self):
self.pictures=Pictures()
self.image1=Image.open(self.pictures.pic2)
self.wpercent=self.w/float(self.image1.size[0])
self.hsize=(int(float(self.image1.size[1])*float(self.wpercent)))
self.image1=self.image1.resize((self.w,self.hsize),Image.ANTIALIAS)
self.image1.save(self.pictures.pic2)
self.canvas.image2 = ImageTk.PhotoImage(self.image1)
self.canvas.itemconfigure(self.item, image = self.canvas.image2 )
self.canvas.grid()
print ("updated")
def buttonclickstart(self):
self.btn1.destroy()
print ("updated1")
self.change_pic()
self.userinput()
python python-3.x tkinter tkinter-canvas
python python-3.x tkinter tkinter-canvas
asked Mar 7 at 18:29
Katie MAISONKatie MAISON
1
1
Have you verified thatchange_pic
is being called? Have you verified thatself.wpercent
andself.hsize
were properly computed? Have you verified that the image which was saved is what you expect?
– Bryan Oakley
Mar 7 at 18:48
Works for me, the image get updated. But i didn'tself.image1.save(...
– stovfl
Mar 7 at 19:18
Change pic is definitely being called as when it is called it prints "updated" which it does after every button press :) wpercent and hsize are correct too and the images are definitely name correctly and in the same folder as my program :) @BryanOakley
– Katie MAISON
Mar 7 at 20:17
add a comment |
Have you verified thatchange_pic
is being called? Have you verified thatself.wpercent
andself.hsize
were properly computed? Have you verified that the image which was saved is what you expect?
– Bryan Oakley
Mar 7 at 18:48
Works for me, the image get updated. But i didn'tself.image1.save(...
– stovfl
Mar 7 at 19:18
Change pic is definitely being called as when it is called it prints "updated" which it does after every button press :) wpercent and hsize are correct too and the images are definitely name correctly and in the same folder as my program :) @BryanOakley
– Katie MAISON
Mar 7 at 20:17
Have you verified that
change_pic
is being called? Have you verified that self.wpercent
and self.hsize
were properly computed? Have you verified that the image which was saved is what you expect?– Bryan Oakley
Mar 7 at 18:48
Have you verified that
change_pic
is being called? Have you verified that self.wpercent
and self.hsize
were properly computed? Have you verified that the image which was saved is what you expect?– Bryan Oakley
Mar 7 at 18:48
Works for me, the image get updated. But i didn't
self.image1.save(...
– stovfl
Mar 7 at 19:18
Works for me, the image get updated. But i didn't
self.image1.save(...
– stovfl
Mar 7 at 19:18
Change pic is definitely being called as when it is called it prints "updated" which it does after every button press :) wpercent and hsize are correct too and the images are definitely name correctly and in the same folder as my program :) @BryanOakley
– Katie MAISON
Mar 7 at 20:17
Change pic is definitely being called as when it is called it prints "updated" which it does after every button press :) wpercent and hsize are correct too and the images are definitely name correctly and in the same folder as my program :) @BryanOakley
– Katie MAISON
Mar 7 at 20:17
add a comment |
0
active
oldest
votes
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',
autoActivateHeartbeat: false,
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
);
);
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%2f55050559%2ftkinter-image-on-canvas-wont-update%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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%2f55050559%2ftkinter-image-on-canvas-wont-update%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
Have you verified that
change_pic
is being called? Have you verified thatself.wpercent
andself.hsize
were properly computed? Have you verified that the image which was saved is what you expect?– Bryan Oakley
Mar 7 at 18:48
Works for me, the image get updated. But i didn't
self.image1.save(...
– stovfl
Mar 7 at 19:18
Change pic is definitely being called as when it is called it prints "updated" which it does after every button press :) wpercent and hsize are correct too and the images are definitely name correctly and in the same folder as my program :) @BryanOakley
– Katie MAISON
Mar 7 at 20:17