Как мне перезапустить init из класса фреймов в tkinter Python?
Это мой код - (удалено много вещей, чтобы упростить его)
class HeadlineGame(tk.Tk):
def __init__(self, *args, **kwargs):
tk.Tk.__init__(self, *args, **kwargs)
self.container = 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 = {}
self.show_frame(StartPage)
moneylabel =tk.Label(self, text="Money: " + str(money))
def show_frame(self, controller):
if controller not in self.frames:
self.frames[controller] = frame = controller(self.container, self)
frame.grid(row=0, column=0, sticky="nsew")
frame = self.frames[controller]
frame.tkraise()
q = 0
y = 0
def multifunction(*args):
for function in args:
function
def publishwindow():
global q
q = 0
def publisharticleimplement():
pass
class StartPage(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
q = 0
while q==0:
print(money)
q = 1
publishimg = tk.PhotoImage(file="assets/publishbutton.png")
cb = lambda: multifunction(controller.show_frame(PublishPage), publishwindow())
publishbutton = tk.Button(self, image=publishimg, borderwidth=0, command= cb)
publishbutton.image = publishimg
publishbutton.place(x=503, y=315)
moneylabel =tk.Label(self, text="Money: " + str(money))
moneylabel.place(x=0, y=360)
class PublishPage(tk.Frame):
def __init__(self, parent, controller):
global money
tk.Frame.__init__(self, parent)
fakelogo = tk.PhotoImage(file="assets/fakenewslogo.png")
publishimg = tk.PhotoImage(file="assets/publishbutton.png")
moneylabel =tk.Label(self, text="Money: " + str(money))
moneylabel.place(x=0, y=360)
def fakechoice():
print('xyz')
cb = lambda: multifunction(controller.show_frame(StartPage), publisharticleimplement())
publisharticle = tk.Button(self, image=publishimg, borderwidth=0, command=cb)
publisharticle.image = publishimg
publisharticle.place(x=503, y=380)
fakechoice()
Я хочу перезапустить init из фрейма начальной страницы класса, чтобы он обновил весь фрейм и перезапустил весь код, а пока l oop.
Есть ли способ достичь этого, вставив код в функцию publisharticleimplement, которая перезапускает def init из StartPage?
Любые решения приветствуются!