RSS Forums RSS
Please support our Python advertiser: Programming Forums
Views: 237 | Replies: 2
Reply
Join Date: Apr 2008
Posts: 4
Reputation: timo_81 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
timo_81 timo_81 is offline Offline
Newbie Poster

count how often a button is clicked python/tk

  #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
  6.  


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

Any suggestions?
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jul 2007
Location: Sofia, Bulgaria
Posts: 138
Reputation: MitkOK is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 10
MitkOK's Avatar
MitkOK MitkOK is offline Offline
Junior Poster

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

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

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

  #3  
Apr 24th, 2008
thanks
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 11:37 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC