Button frames showing/not showing

The idea of the following code is to create a panel which is a subclass of frame, and inside this panel create all the widgets I wish to use. Here I am just asking to create a set of buttons, but for some reason the button frame sometimes is not shown. If I lunch the python program several times, on some occasion I can see the texts but not the background frames of the buttons. I tried using “sortOrder” too, but did not make any difference. Could anybody point me to any mistake I am doing?

import sys
from direct.showbase.ShowBase import ShowBase
from direct.gui.DirectGui import *

class  PanelOverview(DirectFrame):

	def __init__(self, parent=None, **args):
		DirectFrame.__init__(self, parent, **args)
		self['relief'] = DGG.FLAT
		self['frameColor'] = (0.9,0.9,0.0,1)

		self.buttonList = []
		buttonText = ("First","Second","Third","Fourth","Fifth","Sixth")
		self.numButtons = len(buttonText)
		for ii in range(self.numButtons):
					DirectButton( parent = base.render2d, relief = DGG.FLAT, 
							text = buttonText[ii], text_scale = (0.03,0.04), 
							text_align = 2, text_bg = (0, 0, 0, 0), 
							text_pos = (-0.6+0.02+0.085+1.2*(0.02 + 1)*ii/(1.04*self.numButtons), 0.475) 
					) )
			self.buttonList[ii]['frameColor'] = (0., 0.7, 0., 1)
			self.buttonList[ii]['frameSize'] = (-0.6+0.02+1.2*(0.02 + 1)*ii/(1.04*self.numButtons), 
												-0.6+1.2*(0.02+1)*(ii+1)/(1.04*self.numButtons), 0.4, 0.55)

class  App(ShowBase):

	def __init__(self):
		self.accept('escape', sys.exit)
		self.x = PanelOverview( parent = base.render2d, frameSize = (-0.6,0.6,-0.8,0.6) )

app = App()

I note that you seem to be parenting your buttons to render2d–should you not be parenting them to the “PanelOverview” object itself, if you want them to belong to and be shown on top of it?

It makes no difference, I still get the same problem.

My understanding is that parenting to the “PanelOverview” object permits to have the operations applied to this object also applied to its children, but should not affect the order of appearence. What I find weird is that the text always shows up: the background color of the buttons instead seems to show up roughly 50% of the times.

Ok, I experimented further, it looks a bug to me.

It only occurs when parenting to render2d, not to aspect2d.

The problem is as follows. Create a visible DirectFrame and parent it to render2d. Create a DirectButton object (can be any DirectGUI object: another frame, a button. For clarity we now work with a DirectButton) which defines a visible frame of its own, and place it above the frame previously created. The following will occurr:

  1. If the DirectFrame is using a “frameColor” and no texture or geom, and if the button is using a texture or a geom, everything looks fine

  2. If the DirectFrame is using a texture or a geom and the button is using a “frameColor”, the frame of the button is not visible

  3. If the DirectFrame and the button use the same attribute (both ‘frameColor’ or both texture or both geom), the frame of the button appears on a random basis 50% of the times

This behaviour is independent of the fact that the button is parented to render2d or to the DirectFrame object. Also, using sortOrder does not solve the problem.

I am using panda 1.9 on Ubuntu 14.04 - 64 bits.

Please note that I am now using aspect2d so it is not affecting me anymore, still I think that I should report it.