python - Start function on a button in frame tkinter -


i have code open frame. in main frame have button open frame2 (page01). on page01 button make call "function1" defined on top (and it's started when open program, don t want this) , in function1 want call function2 defined in page01.

code  import tkmessagebox import tkinter tk tkinter import * functools import partial import ttk   large_font= ("verdana", 12)  def function1():     print "function 1 started"     #function2()  class changepages(tk.tk):      def __init__(self, *args, **kwargs):         tk.tk.__init__(self, *args, **kwargs)         container = tk.frame(self)         container.pack()         container.grid_rowconfigure(0, weight=1)         container.grid_columnconfigure(0, weight=1)         self.frames = {}         f in (mainpage, page01):              frame = f(container, self)              self.frames[f] = frame              frame.grid(row=0, column=0, sticky="nsew")          self.show_frame(mainpage)      def show_frame(self, cont):          frame = self.frames[cont]         frame.tkraise()  class mainpage(tk.frame):      def __init__(self, parent, controller):          tk.frame.__init__(self,parent)         def c(*args): return partial(self.option_changed, *args)          f = frame(self)         f.pack(side='top')          btnpage01=button(f,text='go pag 01',fg='blue',font=('helvetica',18),height=1, width=10,command=lambda: controller.show_frame(page01))         btnpage01.grid(row=1,column=1)  class page01(tk.frame):      def __init__(self, parent, controller):          tk.frame.__init__(self, parent)         f = frame(self)         f.pack(side='left')          def function2():             print "function 2 started"          bttest = button(f,text='start f',fg='blue',font=('helvetica',26),height=1,width=10,command=function1() )         bttest.grid(row=1,column=1)  #root loop app = changepages() app.geometry('300x200+0+0') app.title('title ') app.mainloop() 

so want : 1- open program - function1 should not start, neither function2 2- open page01 - function1 , 2 stopped 3- press start f , function1 should start , cal function2 start

thanks in advance


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -