Using a "mask" to hide DirectGUI widgets

Hi there,
i would like to make a menu where by scrolling different widgets move up or down. I planned on doing this by listening for mouse wheel events and moving all of the widgets by a constant variable on the height. However, i don’t want them to reach the top of the screen, but stop at just a certain point, when they just sort of fade away and once they are no longer visible they can’t be interacted with. If anyone reading this has ever worked with Adobe tools, it’s kind of like moving text up ad placing a mask at a certain height. I looked a bit through the docs but honestly i don’t even know what to look for exactly because i don’t know what you could use to implement this.

Thanks for your time.

You could perhaps do this with a DirectScrolledFrame, which should provide the scrolling and the overall cutting off of the widgets. The fade could perhaps be done by attaching DirectFrames to the top and bottom of the DirectScrolledFrame, each with a gradient in their alpha (i.e. opacity/transparency) channel.

Thanks a lot Thaumaturge for the help (here and in other questions), but as i am already here, i would like to ask three related things:
How do you set a geometry for the DirectScrollBar that is in the DirectScrolledFrame? is it handled in different pieces, like the bar, the background, and the two buttons?

Is it possible to remove the two buttons of the DirectScrollBar?

Is it possible to access the “value” of the DirectScrollBar and manually change it?
(i would like to listen for mouse wheel movement and adjust the frame accordingly)


It’s not a problem! I’m glad to have helped! :slight_smile:

There are two ways in which you should be able to access those:

The first way is via keyword-parameters.

You see, those scroll-bars are themselves DirectGUI components, contained within the DirectScrolledFrame widget, and thus take keyword-parameters as per usual. To pass parameters to them when constructing the DirectScrolledFrame, just prepend their internal name, followed by an underscore. (Note that this isn’t specific to DirectScrolledFrame; it is I believe fairly general to DirectGUI’s design.)

Something like this:

myScrolledFrame = DirectScrolledFrame(
    # <parameters here as per usual...>

    # Setting up, say, the vertical scroll-bar:
    verticalScroll_frameTexture = "someImage.png",
    verticalScroll_relief = None

    # Sub-components of these components--
    #  e.g. one of the buttons at the end--
    #  are then accessed via another layer
    # of underscores, and so on:
    verticalScroll_incButton_frameTexture = "someOtherImage.png"

You should find a list of relevant keyword-parameters on this manual page, and by clicking on the links to DirectScrolledFrame provided in that list, likewise the parameters for the buttons and thumb.

The second way, done after construction, is to access them as Python variables within the widget.

As mentioned before, these sub-components are just DirectGUI widgets within the main widget. As such, they are often held in variables within the relevant class, and can be accessed as such.

Something like this:

myScrolledFrame = DirectScrolledFrame(
    # <parameters here as per usual ...>

# Altering, say, the vertical scroll-bar
myScrolledFrame.verticalScroll["frameTexture"] = "someImage.png"

# Likewise, the sub-components of sub-components--
#  e.g. the buttons at the end of the scroll-bars--may
#  in some cases be accessible via variables within them:
myScrolledFrame.verticalScroll.incButton["frameTexture"] = "someOtherImage.png"

Hmm… You should be able to hide them, at the least. I’m not sure offhand of whether it’s possible (safely so, at least) to actually remove them.

It is, I do believe!

Something like this:

someScrollBar["value"] = someValue

or like this:


Note that you should be able to get the current value like so:

value = someScrollVar["value"]

or like so:

value = someScrollBar.getValue()
1 Like