The font I’m not sure about–it might be possible, but if so, it may involve digging into the components of the button and manually assigning their fonts. I’m not sure.
The background image, however, is fairly straightforward: Just pass in a list of images, one per state. The states and their order should be the same as those given for passing in multiple geoms, as shown in the page that you linked to.
(That is, in the example on that page just replace “geom=” with “image=”, and the various alls to “maps.find” with the paths to your various images, I believe.)
thanks rdb it’s work
by digging in the code I found your solution:
If a widget has components: 'text1', 'text2', and 'text3' which all belong
to the 'text' group, they can be all configured with keywords of the form:
'text_keyword' (e.g. ``text_font='comic.rgb'``).
I have a last question with directGui, can my widgets be automatically aligned?
i have two buttons:
from panda3d.core import *
from direct.showbase.ShowBase import ShowBase
from direct.gui.DirectGui import *
class MyApp(ShowBase):
def __init__(self):
ShowBase.__init__(self)
myFrame = DirectFrame(frameColor=(0, 0, 0, 1),
frameSize=(-1, 1, -1, 1))
myFrame.setPos(-0.5, 0, -0.5)
b = DirectButton(text=("BTN1"), scale=.05)
b.reparent_to(myFrame)
b = DirectButton(text=("BTN2"), scale=.05)
b.reparent_to(myFrame)
app = MyApp()
app.run()
I would like the first one to be on top of the other (and not interposed)
I can do this with DirectScrolledFrame and the addItem function but can we do it with a frame?
The simplest, but least convenient approach, is to manually position them via the “pos” keyword-parameter.
However, to have them automatically keep their positions relative to each other, you could parent one below the other. (Taking care to not duplicate scales in the child-widgets, as the scales will compound.) This, combined with simpler use of the “pos” keyword-parameter, should allow you to place one button relative to the other–and to have it keep that relative position even if the other is moved.