DirectScrollBar

shouldn’t this work?my button doesnt scroll

self.mainFrame = DirectFrame(frameColor=(0,0,0,1) , frameSize=(-0.5,0.8,-0.8,0.8 ))
        self.mybar = DirectScrollBar(parent = self.mainFrame , range=(0,100), value=50, pageSize=3, orientation= DGG.VERTICAL)
        self.mybar.setPos(0.9,0,0)
        self.client = DirectButton(parent = self.mainFrame, text = ("test"), scale=.05)

All you have done is created a frame and put a scroll bar within it. The scroll bar is not hooked up to anything and won’t automatically scroll the frame unless you program it to.

Maybe you meant to create a DirectScrolledFrame instead, which creates its own scroll bars and hooks them up for you automatically. To use a DirectScrolledFrame, you specify the size of the canvas (which is the virtual canvas that holds your buttons) and parent your buttons to frame.canvas instead of directly to frame.

David

ok, but then how i access scrollbars from scrollframe? just want to make them look nicer?

Have you read the manual page on DirectScrolledFrame?

David

oh missed this
“Parameters to control the look of the vertical scroll bar” :slight_smile:

i create some menu object that makes frame and content. when user navigates it destructs created menus, and creates new.
i have this class for for options menu something like this;

class OptionsMenu:
    def __init__(self):
        self.mainFrame = DirectScrolledFrame(canvasSize = (-0.45,0.75,-2,2), frameSize=(-0.5,0.8,-0.8,0.8 )) 
        self.test = DirectButton(parent = self.mainFrame.getCanvas(), text = ("test"), scale=.05)
    def __del__(self):
        self.mainFrame.destroy()

but when i call destructor i throws me an exception:

Exception exceptions.AttributeError: "'DirectScrolledFrame' object has no attribute 'verticalScroll'" in <bound method OptionsMenu.__del__ of <__main__.OptionsMenu instance at 0x06A11DC8>> ignored

[/code]

and how to suppress keys and mouse? im doing like so:

class MainMenu:
    def __init__(self):
        self.mainFrame = DirectFrame(frameColor=(0,0,0,1) , frameSize=(-1.2,-0.6,0.9,-0.2 ),suppressKeys = 1, suppressMouse = 1 )

but this dosnt work :frowning: maybe im doing something wrong?

The destructor works for me. Perhaps you’re double-destructing your frame? You should understand that any frame (or any other DirectGui object) will automatically be destroyed when its parent DirectGui object is destroyed, so maybe this is happening to your frame, and then you’re destroying it again?

“suppressKeys” and “suppressMouse” are designed to prevent the mouse and key events from being sent to gui objects behind the frame. What effect are you looking for when you say “suppress keys and mouse”?

David

it seems that was double destructor. so when i assing object to var and then assign other obj to that var, phyton calls destructor of the first one. quite cool dont have to clean that garbage i left :smiley:

if suppresing means that if i do something with mouse on frame and my char would not move, then its not working for me :slight_smile:

That isn’t what it means. You can program that kind of suppression yourself. :slight_smile:

David

already did :stuck_out_tongue:
Thanks for the help, i think now i got all the classes that i need, next step is to connect everything :S