Click here to Skip to main content
14,970,106 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
So I don't even know where to begin writing this part of my code --> so there is little sample code to post.

I have figured out how to create PNG files using matplotlib and I want to display them one at a time and advance through them at the click of a TKinter button.

Python
def nextDay():
    print("Next Day")
root = Tk()
photo = PhotoImage(file = "example69.png")
label = Label(root, image=photo).grid(row=0, rowspan=25, column=0)
button4 =Button(root, text="Next Day", command=nextDay).grid(row=3, column=1, sticky=E+W)
root.mainloop()


I can load and display the first one, but I'm really staring at the void when it comes to defining a button function (nextDay) that loops through and changes the photo variable to the next PNG. Do I only need to change it once and let the main loop refresh it? Or do I need to keep a list of PNG files ready to loop through? I have no idea on the latter.

Any suggestions would be greatly appreciated.
Posted

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900