how to toggle event binding on tabs of notebook widget
Question: i have simple application based on tkinter and ttk so i have notebook widget
supposed to creates a limited number of tabs ; and the tabs are the same
thing..but in need to do different actions on each one ..when press some
button a tab with its own name is created and the event binding will be focus
on it..if i selected the previous tab was created with button press..the event
binding will not focus on it nor its children widgets..and this is the problem
i need to solve..can I toggle event binding between tabs??>>any suggestions??
im using python 2.7


Answer: See my answer to question [how to make instances of event for every single tab
on multi tab GUI tkinter( notebook
widget)](http://stackoverflow.com/a/19896049/1832058) to see working example.

I use class `MyTab` to create new tab with own events binding - so I can
create many identical tabs and every tab use own events binding. In example
tabs show different message when you change tab.

You didn't attache code in your question so I can't add more detailed answer.

**EDIT:**

example from previous link + binding to frame:

  * directly in `MyTab` : `self.bind("<Button-1>", self.clickFrame)` (left mouse call function in `MyTab`
  * in `Application` : `tab.bind("<Button-3>", self.clickTab)` (right mouse call function in `Application`

code:

    
    
    #!/usr/bin/env python
    
    from Tkinter import *
    import tkMessageBox
    import ttk
    
    #---------------------------------------------------------------------
    class MyTab(Frame):
    
        def __init__(self, root, name):
            Frame.__init__(self, root)
    
            self.root = root
            self.name = name
    
            self.entry = Entry(self)
            self.entry.pack(side=TOP)
    
            self.entry.bind('<FocusOut>', self.alert)
            self.entry.bind('<Key>', self.printing)
    
            self.bind("<Button-1>", self.clickFrame)
    
        #-------------------------------
    
        def alert(self, event):
            print 'FocusOut event is working for ' + self.name + '  value: ' + self.entry.get()
            #tkMessageBox.showinfo('alert', 'FocusOut event is working for ' + self.name + '  value: ' + self.entry.get())
    
        #-------------------------------
    
        def printing(self, event):
            print event.keysym + ' for ' + self.name
    
        #-------------------------------
    
        def clickFrame(self, event):
            print "MyTab: click at (" + str(event.x) + ", " + str(event.y) + ') for ' + self.name + " (parent name: " + self.root.tab(CURRENT)['text'] + ")"
    
    
    #---------------------------------------------------------------------
    
    class Application():
    
        def __init__(self):
    
            self.tabs = {'ky':1} 
    
            self.root = Tk()
            self.root.minsize(300, 300)
            self.root.geometry("1000x700")
    
            self.notebook = ttk.Notebook(self.root, width=1000, height=650)
    
    #       self.all_tabs = []
    
            self.addTab('tab1')
    
            self.button = Button(self.root, text='generate', command=self.start_generating).pack(side=BOTTOM)
    
            self.notebook.pack(side=TOP)
    
        #-------------------------------
    
        def addTab(self, name):
            tab = MyTab(self.notebook, name)
            tab.bind("<Button-3>", self.clickTab)
            self.notebook.add(tab, text="X-"+name)
    #       self.all_tabs.append(tab)
    
        #-------------------------------
    
        def clickTab(self, event):
            print "Application: click at (" + str(event.x) + ", " + str(event.y) + ') for ' + event.widget.name
    
            #-------------------------------
    
        def start_generating(self):
            if self.tabs['ky'] < 4:
                self.tabs['ky'] += 1
                self.addTab('tab'+ str(self.tabs['ky'])) 
    
        #-------------------------------
    
        def run(self):
            self.root.mainloop()
    
    #----------------------------------------------------------------------
    
    Application().run()     
    

