Problem with multiple sliders

30 views
Skip to first unread message

Victor Leal

unread,
Mar 24, 2019, 10:33:00 AM3/24/19
to Kivy users support
I'm setting up a program to communicate with arduino and one of the parts of that program uses sliders ...

My problem is that when dragging a slider, all others perform their respective functions at the same time.

Python
class Slides(Screen):
   
   def pmove(self, *args):
       value = self.ids.polegar.value
       if(value < 100):
           print("p0" + str(int(value)))
       else:
           print("p" + str(int(value)))

    def imove(self, *args):
       value = self.ids.indicador.value
       if(value < 100):
           print("i0" + str(int(value)))
       else:
           print("i" + str(int(value)))

    def memove(self, *args):
       value = self.ids.medio.value
       if(value < 100):
           print("me0" + str(int(value)))
       else:
           print("me" + str(int(value)))

    def amove(self, *args):
       value = self.ids.anelar.value
       if(value < 100):
           print("a0" + str(int(value)))
       else:
           print("a" + str(int(value)))

    def mimove(self, *args):
       value = self.ids.mindinho.value
       if(value < 100):
           print("mi0" + str(int(value)))
       else:
           print("mi" + str(int(value)))

 

Kivy
ScrollView:
           BoxLayout:
               orientation: 'vertical'
               size_hint: 0.2, None
               height: self.minimum_height
               spacing: 100
               padding: 50
               BoxLayout:
                   spacing: 20
                   Label:
                       text: 'Polegar'
                   Slider:
                       id: polegar
                       size_hint_x: None
                       width: root.width*0.88
                       min: 0
                       max: 180
                       value: 90
                       on_touch_move: root.pmove()
               BoxLayout:
                   spacing: 20
                   Label:
                       text: 'Indicador'
                   Slider:
                       id: indicador
                       size_hint_x: None
                       width: root.width*0.88
                       min: 0
                       max: 180
                       value: 90
                       on_touch_move: root.imove()
               BoxLayout:
                   spacing: 20
                   Label:
                       text: 'Medio'
                   Slider:
                       id: medio
                       size_hint_x: None
                       width: root.width*0.88
                       min: 0
                       max: 180
                       value: 90
                       on_touch_move: root.memove()
               BoxLayout:
                   spacing: 20
                   Label:
                       text: 'Anelar'
                   Slider:
                       id: anelar
                       size_hint_x: None
                       width: root.width*0.88
                       min: 0
                       max: 180
                       value: 90
                       on_touch_move: root.amove()
               BoxLayout:
                   spacing: 20
                   Label:
                       text: 'Mindinho'
                   Slider:
                       id: mindinho
                       size_hint_x: None
                       width: root.width*0.88
                       min: 0
                       max: 180
                       value: 90
                       on_touch_move: root.mimove()



 

Elliot Garbus

unread,
Mar 24, 2019, 12:30:11 PM3/24/19
to kivy-...@googlegroups.com

Short answer:

In KV replace on_touch_move: with on_value:

You can put your print statements into KV, and get rid of the xmove functions you have defined.

 

Detail:

On_touch_move() is called on any mouse movement, and needs to be tested for a collision with the widget.  The mouse messages are passed to all widgets.

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To post to this group, send email to kivy-...@googlegroups.com.
Visit this group at https://groups.google.com/group/kivy-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/166cbf1e-e154-407d-8fd8-d468929c1fba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

 

Victor Leal

unread,
Mar 24, 2019, 1:13:10 PM3/24/19
to Kivy users support
Short answer:
In KV replace on_touch_move: with on_value:
You can put your print statements into KV, and get rid of the xmove functions you have defined.
 
Detail:
On_touch_move() is called on any mouse movement, and needs to be tested for a collision with the widget.  The mouse messages are passed to all widgets.

 

 


Thanks, my problem is gone! :) 
Reply all
Reply to author
Forward
0 new messages