How to reduce the size of the slider knob

102 views
Skip to first unread message

Shoumik Das

unread,
May 25, 2020, 6:18:08 AM5/25/20
to Kivy users support
Hi,

I am trying to create a time selector (hh:mm) using two sliders. This is what it looks like when the window size is large:

If I reduce the window size to simulate a mobile device, the sliders appear a bit cramped:


Is there a way to reduce the size of the knobs of the sliders so as not to overlap with the text? Also, how can I add a thin black border around the box layout so that the cluster of sliders and labels looks like the date field (text-input) on the left?

Thanks in advance

Elliot Garbus

unread,
May 25, 2020, 9:26:29 AM5/25/20
to kivy-...@googlegroups.com

Is there a way to reduce the size of the knobs of the sliders so as not to overlap with the text?

 

See: https://kivy.org/doc/stable/api-kivy.uix.slider.html?highlight=slider#kivy.uix.slider.Slider.cursor_size

The default size is 32x32, you can make is smaller, or change the cursor image.

 

Also, how can I add a thin black border around the box layout so that the cluster of sliders and labels looks like the date field (text-input) on the left?

 

Use the canvas with Line, rectangle to draw a box the size of the boxlayout.  The code below is something similar I did in a different project.  You would use rectangle (not rounded_rectange).

https://kivy.org/doc/stable/api-kivy.graphics.html#kivy.graphics.Line.rectangle

 

BoxLayout:
    orientation:'vertical'
    canvas.after:
        Color:
            rgb: 0, 0, 0
        Line:
            width: dp(2)
            rounded_rectangle: (*self.pos, self.width, self.height, 2)

--
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/5fa0b40e-15ea-4d11-905e-926eabd616bd%40googlegroups.com.

 

Shoumik Das

unread,
May 25, 2020, 11:36:01 AM5/25/20
to Kivy users support
Hi Eliott,

Your suggestions worked like a charm. Thank you very much.

Just one query though: rectangle: (*self.pos, self.width, self.height) - Why are we passing *self.pos instead of self.pos?

Thanks, once again.

To unsubscribe from this group and stop receiving emails from it, send an email to kivy-...@googlegroups.com.

Elliot Garbus

unread,
May 25, 2020, 11:56:39 AM5/25/20
to kivy-...@googlegroups.com

👍😄

If I reduce the window size to simulate a mobile device, the sliders appear a bit cramped:

 

 

Is there a way to reduce the size of the knobs of the sliders so as not to overlap with the text? Also, how can I add a thin black border around the box layout so that the cluster of sliders and labels looks like the date field (text-input) on the left?

 

Thanks in advance

 

--
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/5fa0b40e-15ea-4d11-905e-926eabd616bd%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-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/49666182-d23f-4675-a2f8-ed91744fdc13%40googlegroups.com.

 

Shoumik Das

unread,
May 25, 2020, 12:18:49 PM5/25/20
to kivy-...@googlegroups.com
Hi Eliot,

Can you help me understand this line?

rectangle: (*self.pos, self.width, self.height)

Why are we passing *self.pos instead of self.pos?

Thanks

Elliot Garbus

unread,
May 25, 2020, 12:39:15 PM5/25/20
to kivy-...@googlegroups.com
It unpacks the x and y. 


Sent from my iPhone

On May 25, 2020, at 9:19 AM, Shoumik Das <shoum...@gmail.com> wrote:



Elliot Garbus

unread,
May 25, 2020, 1:00:51 PM5/25/20
to kivy-...@googlegroups.com
...more correctly, it unpacks pos[0], pos[1]

Sent from my iPhone

On May 25, 2020, at 9:39 AM, Elliot Garbus <elli...@cox.net> wrote:

It unpacks the x and y. 

Shoumik Das

unread,
May 25, 2020, 1:05:13 PM5/25/20
to kivy-...@googlegroups.com
Got it! Thanks a ton. 🙂☺️

Reply all
Reply to author
Forward
0 new messages