Set a Scrollbar GUI widget color

Hi, all!

I’ve been trying to tweak a scrolled frame, and everything seems to be working fine except coloring. Here is the code I have for my widget:

DirectScrolledFrame(
            parent=self._main_fr,
            frameSize=(-0.35, 0.3, -0.46, 0.5),
            frameColor=(0, 0, 0, 0),
            canvasSize=(-0.31, 0.3, -1.5, 1.5),
            state=DGG.NORMAL,
            pos=(0, 0, -0.1),
            verticalScroll_frameSize=(-0.002, 0.002, -0.5, 0.5),
            verticalScroll_thumb_frameSize=(-0.002, 0.002, -0.5, 0.5),
            verticalScroll_thumb_frameColor=(0.86, 0.81, 0.77, 1),
            verticalScroll_incButton_relief=None,
            verticalScroll_decButton_relief=None,
            horizontalScroll_relief=None,
            horizontalScroll_thumb_relief=None,
            horizontalScroll_incButton_relief=None,
            horizontalScroll_decButton_relief=None,
        )

I’ve tried to use those arg chains, like verticalScroll_thumb_frameColor, but looks like it’s not working. Maybe you know a way to set a scrollbar color?

Hmm… Based on some experimentation, it seems to work on my end.

What results are you seeing, precisely? And do you perhaps have something above the ScrolledFrame in the scene-graph that might be applying a colour-scale, or some such thing?

Thanks you for the reply.

Here is what I have in code:

    self._main_fr = DirectFrame(
        parent=base.a2dTopLeft,  # noqa: F821
        frameSize=(-0.37, 0.38, -0.6, 0.6),
        state=DGG.NORMAL,
        pos=(0.37, 0, -1),
        frameTexture="gui/tex/paper1.png",
    )
    self._main_fr.setTransparency(TransparencyAttrib.MAlpha)
    self._main_fr.hide()

    self._fr = DirectScrolledFrame(
    parent=self._main_fr,
    frameSize=(-0.35, 0.3, -0.46, 0.5),
    frameColor=(0, 0, 0, 0),
    canvasSize=(-0.31, 0.3, -1.5, 1.5),
    state=DGG.NORMAL,
    pos=(0, 0, -0.1),
    verticalScroll_frameSize=(-0.002, 0.002, -0.5, 0.5),
    verticalScroll_thumb_frameSize=(-0.002, 0.002, -0.5, 0.5),
    verticalScroll_incButton_relief=None,
    verticalScroll_decButton_relief=None,
    horizontalScroll_relief=None,
    horizontalScroll_thumb_relief=None,
    horizontalScroll_incButton_relief=None,
    horizontalScroll_decButton_relief=None,
    )

So, the widget has a parent, but for now I don’t see what can cause the problem.

And here is what I see in the game itself:

What I get if I’m setting verticalScroll_frameColor - looks like the thumb became much smaller (and I can’t change its size), but it got the correct color:

Well, I do think that the size of the thumb is determined automatically, according to the size of the canvas that is to be scrolled. If you have a really big canvas, then you may well end up with a really small thumb. I’m not sure that setting the frame-size actually does anything when applied to the thumb.

However, I may be mistaken in that!

I’ll confess that I’m finding it hard to make out what’s going on with the widget with the bar so very thin–it’s hard for me to tell apart the thumb, the buttons, and the backdrop.

If you don’t mind making a temporary change, how do things look if you make the scroll-bar (including thumb and inc-/dec- buttons) wider, and thus more clearly visible for debugging purposes?

As you say, it seems unlikely that the parent-object is causing the problem, based on what you’ve posted. I suppose that it’s possible that the “frameTexture” is having an effect, so it might be worth experimenting with removing that line in order to determine whether this is the case.

Thaumaturge is right in that the thumb is automatically scaled down to resemble the size of the visible area to the size of the to be scrolled canvas. If you don’t want this, you can set the property resizeThumb on the scrollbars like horizontalScroll_resizeThumb=False and you should be able to retain your manually set thumb size.

1 Like

Ah, changing the size to a wider one helped me to realize what’s happening. The color I’ve tried to set for the scrollbar was too light :grinning_face_with_smiling_eyes: So it was applied correctly from the very beginning, but because of very small size it was really hard to differ the color change.

False alarm, sorry! And thanks.

1 Like