Slider:
id: temperature
value_track: True
value_track_color: [1, 0, 0, 1]
min: 0
max: 16
value: 5
step: 1
orientation: 'horizontal'
on_touch_up: root.get_value()
cursor_image: os.getcwd()+'\\_cursor.png'
background_horizontal: os.getcwd()+'\\_gradient_temperature.png'
Here are 2 ideas for changing the color of the value track color.
You could do something similar and have a number of background images that change based on the value of the slider, if you want to change the background image.
What is the visual effect you want to achieve?
BoxLayout:
orientation: 'vertical'
Slider:
color_value: 5/16
id: temperature
value_track: True
value_track_color: [self.color_value, 0, 0, 1]
min: 0
max: 16
value: 5
step: 1
orientation: 'horizontal'
on_value: self.color_value = self.value_normalized
Slider:
color_value: 5/16
id: temperature
value_track: True
value_track_color: [1, 0, 0, 1]
min: 0
max: 16
value: 5
step: 1
orientation: 'horizontal'
on_value:
if 0 < self.value < 5: self.value_track_color = [1, 0, 0, 1]
if 5 < self.value < 10: self.value_track_color = [1, 1, 0, 1]
if self.value > 10: self.value_track_color = [0, 1, 0, 1]
--
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 view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/88d5d47d-074b-4153-862e-df3b81ed683e%40googlegroups.com.
self.value_track_color = [255, 51, 0, 1]
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-...@googlegroups.com.
self.value_track_color = [255, 51, 0, 1]
Color is expressed between 0 and 1. You could express the values above as: [1, 51/255, 0, 1]
To create the effect your looking for I would suggest deriving a class from Spinner. On the canvas create a rectangle to cover/uncover the background image based on the position of the slider. Give it a try. If you need help let me know.
From: Mart1
Sent: Monday, November 18, 2019 4:13 PM
To: Kivy users support
Subject: Re: [kivy-users] Adjust Slider backgound image on value
Okay not bad at all. value_track_color isn't suppose to be in rgba format ? So why when i putthis below, I have yellow color ? I should have orange nah ??
self.value_track_color = [255, 51, 0, 1]
In my mind I want something like this :
But actully I have this no matter the value :
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/20279b6e-989b-4c0a-a95a-909717767101%40googlegroups.com.
I had some free time… here you go. Add your background gradient this should get you most of the way there.
The canvas is used to draw a black rectangle that matches the background, and covers the ‘track’
from kivy.app import App
from kivy.lang.builder import Builder
kv = '''
<GradientSlider@Slider>
canvas:
Color:
rgba: (0, 0, 0, 1)
Rectangle:
pos: self.value_pos[0] + self.cursor_size[0] / 2 - dp(1.25), self.pos[1]
size: self.size
BoxLayout:
orientation: 'vertical'
GradientSlider:
min: 0
max: 100
value: 50
# add your background color and value_track_color here
Slider:
id:s3
min: 0
max: 100
value_track: True
value_track_color: [1, 0, 0, 1]
Label:
text: str(s3.value_pos)
'''
class GradientSliderApp(App):
def build(self):
return Builder.load_string(kv)
if __name__ == '__main__':
GradientSliderApp().run()
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/5dd33386.1c69fb81.f7802.c8d0SMTPIN_ADDED_MISSING%40gmr-mx.google.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/20279b6e-989b-4c0a-a95a-909717767101%40googlegroups.com.
--
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-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/5dd33386.1c69fb81.f7802.c8d0SMTPIN_ADDED_MISSING%40gmr-mx.google.com.
-sp(32)
<GradientSlider@Slider>
canvas:
Color:
rgba: (0, 0, 0, 1)
Rectangle:
pos: self.value_pos[0] + self.cursor_size[0] / 2 - dp(1.25) - sp(32) , self.pos[1]
size: self.size
The simplest thing to do might be to color the background of the right side of your cursor black, rather than transparent.
From: Mart1
Sent: Tuesday, November 19, 2019 5:27 AM
To: Kivy users support
Subject: Re: [kivy-users] Adjust Slider backgound image on value
Still get a little question about it, how can I put the cursor image upper the black canvas ?
To be clear have this :
Instead of this :
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/e6669f33-29d9-4075-a820-278e5d28f70f%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/e6669f33-29d9-4075-a820-278e5d28f70f%40googlegroups.com.