Toggle layer visiblity

This is probably a simple question, but how do you turn on and off the visibility of an entire layer via python? The point of trying to do this was to keep certain menus on certain layers and just turn on or off the layer rather than adding and then removing (or turning visibility on and off and enabling and disabling) everything. Is this practical or possible? I obviously came here because I couldn’t find any immediate answers via google.

From what I know, you can’t manipulate Blender layers in BGE (I’m not sure if it’s possible, however).
You can, however, make all the GUI layouts visible, each one in different positions on the scene, and simply change the camera position to the desired layout. It’s easier and gives very good results on contextual menus (ex: main menu, pause menu, etc) than hiding objects or changing scenes.

You can’t just makes layers visible or not. You could however just add all all the objects in that layer and end them when you’re done.

all all the objects in that layer and end them when you’re done.

This is actually quite easy as you can add and delete parenting hierarchies just by adding/deleting the top-most parent.

The BGE does not know layers the same way as Blender does.

  • used for separating shading (lights apply to certain layers)
  • active layers = active objects, inactive layers = inactive objects

You can’t change layers nor move objects between layers. This is static.

To achieve what you want you can follow the advice from above.

Another option:

  • Move the camera around
  • move objects (and children around)
  • scale objects
  • visibility actuator (single object only)
  • play animations

just turn on or off the layer rather than adding and then removing (or turning visibility on and off and enabling and disabling) everything. Is this practical or possible?

It is not practical and it is not possible. Even if it was possible still your menus will be re-initialized every time you turn on the layer and you won’t be able to preserver the current state of it (last selected item, text…etc) and you will need to save the state and apply it on each layer turn on/off.