some DirectGui bugs?

Try this:

from panda3d.core import *
import direct.directbase.DirectStart
from direct.gui.DirectGui import *

button = DirectButton(text = 'Hello', text_align = TextNode.ACenter, scale = 0.1)

options = ['Hello', 'Goodbye']
menubutton = DirectOptionMenu(items = options, text_align = TextNode.ACenter, scale = 0.1)


Looks like geometry isn’t updated with the text.

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?

Another thing,


returns None on all the DirectGui classes I tried and


Gives a warning that ‘frame’ doesn’t exist.





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:

background = DirectFrame(frameColor=(0,0,0,0.4), 
button = DirectButton(text='Hello', text_font=loader.loadFont("cmss12"), pos=(0,0,-0.025), scale=0.1, text_fg=(1,1,1,1),	frameColor=(0,0,0,0))

… where you set the frame of the button to transparent. At least that’s how I do it.

Panda is a bit weird with alignments. Do

menubutton = DirectOptionMenu(items=options, text_align=TextNode.ALeft, scale=0.1)

and it looks alright.

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:
(all display modules loaded.)
>>> from direct.gui.DirectGui import *
>>> menu = DirectOptionMenu()
>>> print menu['frameSize']

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.