Python Forum
[Kivy] Not listen for multi clicks
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Kivy] Not listen for multi clicks
#1
Hi, I have Kivy app that sometimes making some heavy stuff.
It makes the user to sometimes click/touch two/three times, but I wish to ignore this click.
Right now, the clicks "saves" and will be executed after the first click.

My goal is to ignore them. Is it possible?

example.kv
<Upload>
    name:"upload"
    BoxLayout:
        orientation: 'vertical'
        Label:
            id: nr_label
            size_hint: (1, 1)
            font_size:24
            text: "0"
        Button:
            size_hint: (1, 1)
            text: "Increase"
            on_release: root.increase()
class Upload(Screen):
    nr = 0

    def increase(self):
        self.nr += 1
        sleep(1)  # Do some heavy stuff
        self.ids.nr_label.text = str(self.nr)
If I run this example the app lock the button in one second, and after that I don't want anything to happen, even if I have click multi times on the button.
Reply
#2
change
Quote: def increase(self):
self.nr += 1
sleep(1) # Do some heavy stuff
self.ids.nr_label.text = str(self.nr)
to

 if self.nr == 0:
        self.nr = 1
        self.ids.nr_label.text = str(self.nr)
    else: return()
You seem to be thinking that the sleep will allow something else to be going on but it won't.
Reply
#3
(Nov-18-2021, 02:02 PM)Barrowman Wrote: change
Quote: def increase(self):
self.nr += 1
sleep(1) # Do some heavy stuff
self.ids.nr_label.text = str(self.nr)
to

 if self.nr == 0:
        self.nr = 1
        self.ids.nr_label.text = str(self.nr)
    else: return()
You seem to be thinking that the sleep will allow something else to be going on but it won't.

The row:
sleep(1) # Do some heavy stuff
is for simulate some slow processes, in my case it's a bluetooth communication that some time takes 1-2 second
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question [Tkinter] Checkbutton clicks events does not update visually. nicolaask 1 2,985 Dec-20-2020, 06:11 PM
Last Post: nicolaask

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020