I don’t know how to go back to the function 'to_be', exit the function.
#!/usr/bin/python3.4 #-*- coding: utf-8 -*- try: # python2 from Tkinter import * except ImportError: # python3 from tkinter import * root = Tk() root.title('MyGui') root.geometry('600x600') def clear(): # очистить фрейм от виджетов if frm.winfo_children(): frm.winfo_children()[0].destroy() def to_be(event): clear() lab = Label(frm, text='What time is it?') clear() lab.place(relx=0.5, rely=0.5, anchor='center') but = Button(frm, text='home') but.place(relx=0.7, rely=0.7, anchor='center') # здесь мне нужно вернуться в начало программы but.bind('<Button-1>', 'по нажатию кнопки нужно выйти из функции') frm = Frame(root, width=500, height=500, bg='#008B8B') lab = Label(frm, text='Глагол to be', bg='#008B8B', font='Inconsolata 13') lab.place(x=250, y=10, anchor='center') but = Button(frm, text='Ok', bg='blue') but.place(x=200, y=20, width=100) frm.pack() but.bind('<Button-1>', to_be) root.focus_force() root.mainloop()
to_be()function after the execution ofbut.bind(...). Write what exactly you want to do, what does “go back” mean? - insolor