DirectGUI problems

Hi,

I have tried to migrate my project to panda3d 1.3 (thanks for the release). However i got a problem. As the manual says “from direct.gui.DirectGui import *” should import all important stuff, however the SUNKEN, RAISED, GROOVE, RIDGE, FLAT variables are no more imported. Is this a bug or do is it meant to be imported from somewhere different?

Reto

The problem is that “import *” used to import so many symbols that it would end up accidentally overwriting things that the user wasn’t expecting it to overwrite. This was creating unpredictable behavior from one version to the next.

To avoid that problem we’ve created a new rule: “import *” only imports classes and functions. Constants aren’t imported. So if you want to access those constants, you have to either import them explicitly, like this:

from direct.gui.DirectGui import RAISED, SUNKEN, etc

Or, you can import the module itself like this:

import direct.gui.DirectGui as dgui

And then you can refer to dgui.RAISED, dgui.SUNKEN, etc.

You can also just reference the symbols using the DGG prefix, e.g. DGG.SUNKEN, DGG.RAISED, etc. The name DGG stands for DirectGuiGlobals. The symbols are available under the DGG prefix even when you just do “from direct.gui.DirectGui import *”.

David