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:
But if I flip the width/height, it looks like my x,y coordinates also don't work:
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: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):
-
@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.
In both these cases, it seems right that the current
_isVertical()
would returnFalse
whenw == h
(when both are -10) andTrue
when180 > -10
, so if_isVertical()
returnsw < 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()
ifself._isVertical()
returnsTrue
whenw > 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.