I’m new to Panda3D and I have an issue with the DirectOptionMenu. When i use a custom font, only the selected entry is drawn with the font. The others entries still use the system standard font. Here is my
from direct.showbase.ShowBase import ShowBase
from direct.gui.DirectGui import DirectOptionMenu
base = ShowBase()
font_ka1 = base.loader.loadFont('ka1.ttf')
menu = DirectOptionMenu(scale=0.1,items=["item1","item2","item3"],text_font=font_ka1)
I’ve read a lot of code snippets but still couldn’t figure how to make it work.
Thanks for your help.
Simply put, the styling of the items in a DirectOptionMenu comes from their own, separate set of keyword-parameters, starting with the prefix “item_”. Like the parameters that you’re using, these are passed into the constructor of the DirectOptionMenu.
So, for example, if you wanted to change the colour of the menu itself, you would pass in “frameColor = <colour-value>”, and if you want to change the colour of the menu-items, you would instead pass in “item_frameColor = <colour-value>”.
In the case of the font used for item-text, you would thus pass in “item_text_font = <font-object>”.
(I presume that you still want the selected item to be rendered in this font, so you would thus presumably leave the current “text_font” parameter in place, too.)
Something like this:
menu = DirectOptionMenu(scale = 0.1,
items = ["item1", "item2", "item3"],
text_font = font_ka1,
item_text_font = font_ka1)