0

I would like to have a slider with multiple values and binding to multiple buttons in kivy. I thought it's a good idea, to modify the original slider code, but if I change the class name, this slider stops to display anything.

I read Use custom widgets kivy and Kivy - Create new widget and set its position and size and thought it would be possible and feasable.

I noticed, that all the images are registered in the Atlas picture database. So to check if their naming convention (https://kivy.org/doc/stable/api-kivy.atlas.html) is checked somehow, I copied and changed their name to 'sliderx' also, as well their filenames and their names in the defaulttheme. But with no effect, neither error, nor function. Are the widgets registered somewhere else? Although, if there are these images, I would like to reuse these pictures for simplicity, so I would like to circumvent this.

You can take the whole code from this file and run it to see a normal slider as example. Then replace the name of the class and in the build method with 'sliderx' resp. 'Sliderx':

https://github.com/kivy/kivy/blob/master/kivy/uix/slider.py

I get a black screen app instead of the normal slider widget, that I expected.


Edit

Thanks to John Andersons tip with inheritance this may work. It's possible to get multiple buttons so far. enter image description here

Prodiction
  • 187
  • 12
  • please post a [mcve]. – John Anderson Sep 03 '19 at 16:41
  • 1
    Have you considered using [inheritance](https://docs.python.org/3.6/tutorial/classes.html?highlight=extend%20class#inheritance) instead of redefining the entire class? – John Anderson Sep 03 '19 at 16:50
  • See, it works because of your comment. Have you some idea, why overloading is here appropriate except avoiding boilerplate? – Prodiction Sep 03 '19 at 18:42
  • I thought not to post some half deleted file, because the minimal example is in that kivy code file in `main` and the rest, the `Slider`-class seems to be important for defining a new special slider. – Prodiction Sep 03 '19 at 18:47

0 Answers0