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?










0















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()









share|improve this question






















  • 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











  • 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
















0















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()









share|improve this question






















  • 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











  • 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














0












0








0








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()









share|improve this question














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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 7 at 18:29









Katie MAISONKatie MAISON

1




1












  • 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











  • 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











  • 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

















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













0






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',
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
);



);













draft saved

draft discarded


















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















draft saved

draft discarded
















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved