simple menu [broken]

I’m not sure if this is the right place to post it but a really simple menu would also be a good feature, I think.

For a simpleMenu you just need two images: One actually showing what the user should see (screen) and one with the buttons painted on it in different, preferably solid colors (menu).
When you click somewhere an event is fired with the color of the pixel in the menu-image you clicked on.

One good thing about it is that someone can make the whole menu (almost) without restrictions in a short time and doesn’t have to know anything about Panda3D or Python.

simpleMenu.zip (first version)
SimpleMenu2.zip (better example)
simpleMenu3.zip (overlay added)
simpleMenu4.zip (hexfmt corrected, loading from textfiles added)

Very interesting idea!
Will definately look into it

I added a better example. (new link)
Im not sure if adding support for movie-textures would be good as then i would have to change to Texture input instead of PNMImage and the push/pop-mechanism would become more complicated.
What do you think?

I added support for overlays so you now can actually make menu-trees or popup menus. (see first post for link)

I’m planning to add the option to load a menu from a simple file next.

Now menus can also be defined using ini-syntax and loaded.

It doesn’t work for me. I get the following errors:

:pnmimage(error): Could not read image testmenu.png
:pnmimage(error): Could not read image testscreentrans.png
Assertion failed: _num_channels >= 1 && _num_channels <= 4 at line 88 of built/include/pnmImageHeader.I
Assertion failed: false at line 3711 of panda/src/gobj/texture.cxx
Traceback (most recent call last):
  File "/home/karolis/Downloads/simpleMenu/test.py", line 13, in <module>
    sm.push(PNMImage("testmenu.png"), PNMImage("testscreentrans.png"), "First", lambda c: dict(red="SomeThingWeird", yellow="Box", blue="Circle", white="")[vgafmt(c)])
  File "/home/karolis/Downloads/simpleMenu/sime.py", line 111, in push
    self.update(menu, screen, prefix, colfmt, overlay)
  File "/home/karolis/Downloads/simpleMenu/sime.py", line 54, in update
    tex.load(self.screen)
AssertionError: _num_channels >= 1 && _num_channels <= 4 at line 88 of built/include/pnmImageHeader.I

I’m using Panda 1.7 and Kubuntu Linux 9.10

thanks for the bugreport

allthough it ran fine on my other machine i tested again and i could not reproduce this error on xp but i got another error because of the image-size which has to be rescaled to power of two eg 1024x1024

when i do this i get another error - dictionary key error which i dont understand so this is not usable anyway - sorry