New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multi Touch event issue in kivy #5295
Comments
Unless there's a reproducible example, the issue is most likely in your code. Therefore please read again the issue template and submit the appropriate stuff otherwise it's only about guessing. |
this is the code i used, please look into it., so how do I manage two sliders ? Kivy Example App for the slider widgetfrom kivy.app import App
from kivy.uix.gridlayout import GridLayout
from kivy.uix.slider import Slider
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.properties import (NumericProperty, AliasProperty, OptionProperty,
ReferenceListProperty, BoundedNumericProperty,
StringProperty, ListProperty, BooleanProperty)
class WidgetContainer(GridLayout):
def __init__(self, **kwargs):
super(WidgetContainer, self).__init__(**kwargs)
# 2 columns in grid layout
self.cols = 4
self.velocity = Slider(min=-100, max =100, value=0, orientation = 'vertical',
value_track_width = '3dp',value_track=True, cursor_width = '36sp', cursor_height = '36sp')
self.steering = Slider(min=-100, max=100, value=0)
#3rd
self.add_widget(Label(text='position'))
self.angle = Label(text='0')
self.add_widget(self.angle)
#angle bind
self.steering.bind(value=self.valu)
# 4th
self.add_widget(Label(text='speed'))
self.speed = Label(text='0')
self.add_widget(self.speed)
self.velocity.bind(value=self.val)
self.add_widget(Label(text='steering'))
self.add_widget(self.steering)
self.add_widget(Label(text='acceleration'))
self.add_widget(self.velocity)
def val(self, instance, speed):
self.speed.text = "%d"%speed
def valu(self, instance, angle):
self.angle.text = "%d"%angle
def on_touch_up(self, touch):
self.clear_widgets()
self.__init__()
# touch is on the button...do not want to send this event any further
return False
# The app class
class SliderExample(App):
def build(self):
widgetContainer = WidgetContainer()
return widgetContainer
# Run the app
if __name__ == '__main__':
SliderExample().run() |
class WidgetContainer(GridLayout):
# Sliders spawned in __init__()
def on_touch_up(self, touch): # this, bad!
self.clear_widgets()
self.__init__() What you basically did is that you removed the sliders and added new ones on each time a touch from the There's nothing wrong with multitouch, only you choose a very bad method of resetting two widgets via removing the whole parent's content instead of editing the widget's behavior only. |
can u suggest a best way for it? |
I already did. Reset the touch in the widget instance only, not in its parent. For example: class MySlider(Slider):
def on_touch_up(self, touch):
# do stuff here e.g. |
okay i think i almost did, yet I'm facing a new problem !!
|
Hi,
Actually I'm working on an application in kivy and the main part is using 2 sliders that are able to reset to its initial state when released.
ISSUE here is: Both the sliders are being used .,when one is released, the other one is also going back to its initial state. is there any way to overcome this??
The text was updated successfully, but these errors were encountered: