AssertionError using DirectButton

Hi - I’m trying to create a DirectButton for a login screen. I want to use 4 separate images for the various button states, and I tried to follow the directions given in the Panda manual. I used egg-texture-cards to create an egg with all four images (.jpg’s) and then wrote the following code:


        # Add a button graphic to cover the cruddy popup marker
        maps = loader.loadModel('LoginListButton.egg')
        jobListButton = DirectButton(relief = None,
                                     geom = (maps.find('arrow_ready'),
                                             maps.find('arrow_press'),
                                             maps.find('arrow_rollover'),
                                             maps.find('arrow_disabled')),
                                     geom_scale = (geomScale, geomScale,
                                                   geomScale),
                                     frameSize = (0, w, -0.2, 0.9))

When I run my program, I receive the following error:


C:\_code\Panda\InterfaceTest>ppython InterfaceTest.py
DirectStart: Starting the game.
Warning: DirectNotify: category 'Interval' already exists
Known pipe types:
  wglGraphicsPipe
(3 aux display modules not yet loaded.)
Assertion failed: !is_empty() at line 429 of panda/src/pgraph/nodePath.cxx
Traceback (most recent call last):
  File "InterfaceTest.py", line 261, in ?
    interface = InterfaceTest()
  File "InterfaceTest.py", line 54, in __init__
    self.initLoginScreen()
  File "InterfaceTest.py", line 117, in initLoginScreen
    fieldLong)
  File "InterfaceTest.py", line 234, in createLoginList
    frameSize = (0, w, -0.2, 0.9))
  File "C:\Panda3D-1.0.5\direct\src\gui\DirectButton.py", line 61, in __init__
    self.initialiseoptions(DirectButton)
  File "C:\Panda3D-1.0.5\direct\src\gui\DirectGuiBase.py", line 236, in initialiseoptions
    func()
  File "C:\Panda3D-1.0.5\direct\src\gui\DirectFrame.py", line 118, in setGeom
    sort = GEOM_SORT_INDEX)
  File "C:\Panda3D-1.0.5\direct\src\gui\DirectGuiBase.py", line 556, in createcomponent
    widget = apply(widgetClass, widgetArgs, kw)
  File "C:\Panda3D-1.0.5\direct\src\gui\OnscreenGeom.py", line 49, in __init__
    self.assign(geom.copyTo(parent, self.sort))
  File "NodePath", line 12387, in copyTo
  File "NodePath", line 1260, in __overloaded_copyTo_ptrConstNodePath_ptrConstNodePath_int
AssertionError: !is_empty() at line 429 of panda/src/pgraph/nodePath.cxx

If I change the button’s ‘geom’ parameter to simply:


geom = maps,

then the buttons appear, but the textures constantly cycle through the 4 packaged in the egg.

Can anyone tell me what I’m doing wrong? Thanks for you help!

  • Ogel

When looking for geometry, use “**/” in your string to search down the hierarchy of nodes. like this:


maps.find("**/arrow_ready")

The “**” is a wild card character that matches a sequence of zero or more nodes in the tree with any name.

Corrected the DirectButton section so it reflects this

I was searching this problem, and met up with this post, so instead of posting new, I thought I would ask here.

I followed the manual to a T

 egg-texture-cards -o button_maps.egg -p 240,240 button_ready.png button_click.png button_rollover.png button_disabled.png 

maps = loader.loadModel(‘button_maps.egg’)
b = DirectButton(geom = (maps.find(’/button_ready’),
maps.find(’
/button_click’),
maps.find(’/button_rollover’),
maps.find(’
/button_disabled’)))

… and got this error in the last 4 lines:

    world.start()

File “proj001.py”, line 83, in start
self.button = DirectButton(geom = (maps.find(’**/button_ready’),
AttributeError: ‘NoneType’ object has no attribute ‘find’

In fact I tried using find before and always get the same message.
Can you please tell me what I am doing wrong? Thanks

OK. Dont bother. I started over fresh, and didn’t get an error. So I suppose there was some clash in code.