May-09-2020, 02:56 PM
Hello,
I am having some troubles with my code.
My problem is that I have defined a canvas with a button and I want that when I click on that button, I go to the frame which is define inside a fonction. I have been trying to do that but I didn't succeed. If you have an idea, it would be awesome.
Thanks a lot and have a nice day
Here is an example of the form of my code.
On that code, I want the button in def welcome to make the function TheOtherFunction runs and this function will make the ExampleFunctions runs.
I am having some troubles with my code.
My problem is that I have defined a canvas with a button and I want that when I click on that button, I go to the frame which is define inside a fonction. I have been trying to do that but I didn't succeed. If you have an idea, it would be awesome.
Thanks a lot and have a nice day
Here is an example of the form of my code.
On that code, I want the button in def welcome to make the function TheOtherFunction runs and this function will make the ExampleFunctions runs.
from tkinter import Tk, Canvas, Button, Frame, PhotoImage, IntVar, Label, Radiobutton def welcome() : for c in window.winfo_children(): c.pack_forget() canvample = Canvas(window, width=680, height=600, bg="#FFFFFF") picexample = PhotoImage(file = "example.png") gifsdict["example.png"] = picexample canvample.create_image(540, 340, image=picexample) Button(window, text='exammmple', command=TheOtherFunction(table, window)).place(x=100,y=190) txt1 = canvample.create_text(250,220,text="exammmplleee") canvample.pack() def ExampleFunction(table, string1, int1, string2, window): for c in window.winfo_children(): c.destroy() frameeee = Frame(window) def okay(ans): if ans ==0 : i = i+5 TheOtherFunction (table, window) if ans ==6 : i = i-1 TheOtherFunction (table, window) ans_choice = IntVar() ans_choice1 = Radiobutton(frame1, text="lalala", variable=ans_choice, value=0) ans_choice2 = Radiobutton(frame1, text="blablabla", variable=ans_choice, value=2) OkayButton = Button(frame1, text="Okay", command=lambda: okay(ans_choice.get())) ans_choice1.pack() ans_choice2.pack() OkayButton.pack() frameee.pack() def TheOtherFunction(table, window): string1 = "mamma mia" int1 = 20 string2 = "so funny" ExampleFunction(table, string1,int1, string2, window) endframe = Frame(window) if i <= -5: lno = Label(framefin, text="no") lno.pack() framefin.pack window = Tk() window.geometry("680x600") gifsdict={} pagebienvenue() window.mainloop()