Nov-18-2019, 04:41 PM
Hello,
I have a problem with Tkinter to exchange and update variable. I tried inheritance, doing an other interface...)
Below an example
I have a problem with Tkinter to exchange and update variable. I tried inheritance, doing an other interface...)
Below an example
import tkinter as tk from tkinter import ttk LARGE_FONT= ("Verdana", 12) class Mainapp(tk.Tk): def __init__(self, *args, **kwargs): tk.Tk.__init__(self, *args, **kwargs) #tk.Tk.iconbitmap(self,default='clienticon.ico') tk.Tk.wm_title(self, "Sea of BTC Client") container = tk.Frame(self) container.pack(side="top", fill="both", expand = True) container.grid_rowconfigure(0, weight=1) container.grid_columnconfigure(0, weight=1) self.frames = {} for F in (StartPage, PageOne): frame = F(container, self) self.frames[F] = frame frame.grid(row=0, column=0, sticky="nsew") self.show_frame(StartPage) def show_frame(self, cont): frame = self.frames[cont] frame.tkraise() class StartPage(tk.Frame): def __init__(self, parent, controller): tk.Frame.__init__(self,parent) self.VARIABLEtoCHANGE=IntVar() self.VARIABLEtoCHANGE=1 label = ttk.Label(self, text="Start Page", font=LARGE_FONT) label.pack(pady=10,padx=10) button = ttk.Button(self, text="Go to change value on Page 1", command=lambda: controller.show_frame(PageOne)) button.pack() label=ttk.Label(self,text=self.VARIABLEtoCHANGE).pack() class PageOne(tk.Frame): def __init__(self, parent, controller): tk.Frame.__init__(self,parent) self.VARIABLEtoCHANGE=2 label = ttk.Label(self, text="Page One!!!", font=LARGE_FONT) label.pack(pady=10,padx=10) button1 = ttk.Button(self, text="Back to Home", command=lambda: controller.show_frame(StartPage)) button1.pack() button2 = ttk.Button(self, text="Change Value", command=lambda: controller.StartPage.VARIABLEtoCHANGE) button2.pack() app = Mainapp() app.mainloop()Thanks for your help