Another oddity I noticed, with the default relief mode for DirectButton.
I’m writing code which automates button placement on a frame, by using the previous nodes position and its frame size (button.getHeight()).
Seems to work fine except when you use the default relief mode.
Looks like the “inner” plane’s bounds are used, not the “outher”. I don’t think that’s right. Why would you want to know the size of that anyway?
DirectButton.getBounds()
DirectButton.getHeight()
etc.
and
DirectOptionMenu["frameSize"]
do work.
Regarding your original question I don’t know. It should work, simple enough. However, I guess DirectButton should not be used without a background:
Well, for your first snippet, I didn’t say it doesn’t “work”, I say the height you get with getHeight() doesn’t correspond to the frame’s actual height, if using DGG.RAISED or DGG.SUNKEN render modes, as you can see in the image where I use that value to position one object right below another.
As for the second code snippet, it only “works” as in doesn’t crash. But it returns None.
>>> from panda3d.core import *
>>> import direct.directbase.DirectStart
DirectStart: Starting the game.
Known pipe types:
wglGraphicsPipe
(all display modules loaded.)
>>> from direct.gui.DirectGui import *
>>> menu = DirectOptionMenu()
>>> print menu['frameSize']
None
Sorry, but what first question do you mean? Do you by any chance mean the second one (the one about not being able to get actual button height?).
From my experience DirectButton doesn’t require you to create a frame yourself, it has its own (if by “background” you mean “frame”, that is).
Sorry, but you just showed how left alignement works alright. I’m talking about aligning to center. That’s not really a workaround.
It’s possible that DirectCheckButton only supports left and right alignement.