SOLVED vanilla.Slider width/height



  • Hi, I'm updating an old script and I'm having some problems with Slider direction. Wondering if it's related to the comments on this commit and if there's a good way around it for now.

    This code: self.w.xHeightSlider = Slider((x+2, row2+22, 194, 25)...

    produces this:

    0_1540998934485_Screen Shot 2018-10-31 at 11.15.19 AM.png

    But if I flip the width/height, it looks like my x,y coordinates also don't work:

    0_1540998906314_Screen Shot 2018-10-31 at 11.14.25 AM.png

    Seems like something like self.w.xHeightSlider = Slider((x+2, row2+22, 194, 195) works, but I'd have to decrease the y value a lot:

    0_1540999219525_Screen Shot 2018-10-31 at 11.18.34 AM.png

    I can't set the width to -10 because there are more UI elements next to the slider.

    Thanks!



  • @gferreira Thanks for helping!



  • hmm, I'm getting a horizontal slider in Demo1

    you are right — it was a typo :) (fixed in the code sample, thanks!)

    I get the same results (macOS 10.13 / RF 3.2b):

    0_1541023696155_Screen Shot 2018-10-31 at 19.08.01.png 1_1541023696159_Screen Shot 2018-10-31 at 19.08.04.png



  • @gferreira hmm, I'm getting a horizontal slider in Demo1—although as a user, I think this is what I would expect, since I'm specifying the width first.
    0_1541021986884_Screen Shot 2018-10-31 at 5.39.34 PM.png

    In both these cases, it seems right that the current _isVertical() would return False when w == h (when both are -10) and True when 180 > -10, so if _isVertical() returns w < h instead, then the Slider would be horizontal in both cases.

    I've opened an issue, so we'll see.



  • @jesentanadi good point. looking closer into it, I see that the Slider gets a different orientation if the width is specified as a positive or negative integer:

    from vanilla import Window, Slider
    
    class SliderDemo1(object):
    
        # width as negative number (relative to parent object)
        # slider is horizontal = CORRECT
    
        def __init__(self):
            self.w = Window((200, 100), title='demo 1')
            self.w.slider = Slider((10, 10, -10, -10))
            self.w.open()
    
    class SliderDemo2(object):
    
        # width as positive number (absolute value)
        # slider is vertical = WRONG!
    
        def __init__(self):
            self.w = Window((200, 100), title='demo 2')
            self.w.slider = Slider((10, 10, 180, -10))
            self.w.open()
    
    SliderDemo1()
    SliderDemo2()
    

    I think it really is a bug, and we need to reopen issue #58



  • @gferreira That works, thanks!

    I'm on macOS 10.13, but running RF3.1.

    I'm still confused about why, in your case, it works without the explicit setVertical() if self._isVertical() returns True when w > h.



  • some background info: How can I make a vertical slider?



  • hi. I also came across this bug some time ago… you can temporarily fix it like this:

    self.w.slider.getNSSlider().setVertical_(True) # or False
    

    which version of macOS are you running? which version of RF3?

    I think this problem happens only in macOS 10.12 (??) – it’s working fine for me on macOS 10.13 using the latest 3.2 beta.


Log in to reply