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:

click=0
      def button_clicked():
       click=click+1
       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?

Recommended Answers

All 2 Replies

click=0
      def button_clicked():
       global click
       click=click+1
       print click

thanks ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.