Button Problem

I am having a strange problem with using buttons. This is my code to show a button:

lumberMillImage = loader.loadModel("Images/lumberMillButton");
        self.lumberMillButton = DirectButton(geom = (lumberMillImage.find('**/lumberMillButton'),
                         lumberMillImage.find('**/lumberMillButton'),
                         lumberMillImage.find('**/lumberMillButton'),
                         lumberMillImage.find('**/lumberMillButton')), 
                         relief=None, command=self.BuildBuilding, extraArgs=["LumberMill"]);
        self.lumberMillButton.reparentTo(aspect2d);
        self.lumberMillButton.setPos(1.1, 0, -.55);

It was all working fine until I tried to use a different button with it. I am creating the button using this command line text:

egg-texture-cards -o lumberMillButton.egg -fps 0 -p 256,256 LumberButton.png

The error I get is:

hunterLoungeImage.find('**/huntersLoungeButton')), relief=None, command=self.BuildBuilding, extraArgs=["HuntersLounge"]);
  File "C:\Panda3D-1.5.4\direct\src\gui\DirectButton.py", line 62, in __init__
    self.initialiseoptions(DirectButton)
  File "C:\Panda3D-1.5.4\direct\src\gui\DirectGuiBase.py", line 241, in initialiseoptions
    func()
  File "C:\Panda3D-1.5.4\direct\src\gui\DirectFrame.py", line 132, in setGeom
    sort = DGG.GEOM_SORT_INDEX)
  File "C:\Panda3D-1.5.4\direct\src\gui\DirectGuiBase.py", line 561, in createcomponent
    widget = apply(widgetClass, widgetArgs, kw)
  File "C:\Panda3D-1.5.4\direct\src\gui\OnscreenGeom.py", line 49, in __init__
    self.setGeom(geom, parent = parent, sort = sort, color = color)
  File "C:\Panda3D-1.5.4\direct\src\gui\OnscreenGeom.py", line 96, in setGeom
    self.assign(geom.copyTo(parent, sort))
AssertionError: !is_empty() at line 461 of panda/src/pgraph/nodePath.cxx

Like I said, this still works if I use the old .egg image I created but it will not work when I create a .egg with a new image. If you need to see them, these are the images I am using and their corresponding .egg files

Old working files - mediafire.com/?sharekey=14d0 … 6e282a0ee8

New non-working files - mediafire.com/?sharekey=14d0 … 49b5870170

Thanks for any help you may be able to give.
[/code]

AssertionError: !is_empty()

This is the sort of message you get when you try to use the result of a failed find operation.

lumberMillImage.find('**/lumberMillButton')

This function call is looking for a texture card named “lumberMillButton” in the egg file you loaded. The program egg-texture-cards names cards based on the image filenames. So unless you added a lumberMillButton.png file to the egg-texture-cards command line, I would expect this find operation to fail.

David

Thanks for the quick response. I fixed that problem. Now I have a different one. I have been parenting the buttons to aspect2d and it has been working fine. Now, I wish to parent them to render2d so that I can easily scale them bases on pixel widths and heights(I do not know an easy way to do this on aspect2d). The button is no longer clickable on render2d. Is there a way to make a button parented to render2d clickable?

No, aspect2d is the magic node that makes buttons clickable. You could set:

aspect-ratio 1

in your Config.prc file, which will remove the default scale on aspect2d. Or, you could set the scale relative to render2d, e.g.

button.setScale(render2d, 0.1, 0.1, 0.1)

David