Binding an event with an event handler : Event : GUI Tk PYTHON examples


PYTHON examples » GUI Tk » Event »

 

Binding an event with an event handler


Binding an event with an event handler
 
from Tkinter import *

class Application(Frame):
    def __init__(self, master):
        Frame.__init__(self, master)
        self.grid()
        self.bttn_clicks = 0    
        self.create_widget()

    def create_widget(self):
        self.bttn = Button(self)
        self.bttn["text"]"Total Clicks: 0"
        self.bttn["command"= self.update_count
        self.bttn.grid()

    def update_count(self):
        self.bttn_clicks += 1
        self.bttn["text""Total Clicks: " + str(self.bttn_clicks)
          
root = Tk()
root.geometry("200x50")
app = Application(root)
root.mainloop()

           
         
  



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON examples

 Navioo GUI Tk
» Event