count how often a button is clicked python/tk

Reply

Join Date: Apr 2008
Posts: 4
Reputation: timo_81 is an unknown quantity at this point 
Solved Threads: 0
timo_81 timo_81 is offline Offline
Newbie Poster

count how often a button is clicked python/tk

 
0
  #1
Apr 24th, 2008
Hi,
I wanted to ask if somebody could help me on the following problem:

I want to check how often a button in python/tk is clicked.

I tried the folowing but it doesn't work:


  1.  
  2. click=0
  3. def button_clicked():
  4. click=click+1
  5. print click


but this won't work because the variable click in the function is different(local) to the
variable outside of the function.

Any suggestions?
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 142
Reputation: MitkOK is an unknown quantity at this point 
Solved Threads: 12
MitkOK's Avatar
MitkOK MitkOK is offline Offline
Junior Poster

Re: count how often a button is clicked python/tk

 
0
  #2
Apr 24th, 2008
  1. click=0
  2. def button_clicked():
  3. global click
  4. click=click+1
  5. print click
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 4
Reputation: timo_81 is an unknown quantity at this point 
Solved Threads: 0
timo_81 timo_81 is offline Offline
Newbie Poster

Re: count how often a button is clicked python/tk

 
0
  #3
Apr 24th, 2008
thanks
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Python Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC