Dialogs and p3d

Hello, I’ve a problem when I try to use DirectGUI dialogs inside p3d files.

I’ve this file main.py:

import direct.directbase.DirectStart
from direct.gui.DirectDialog import OkDialog
OkDialog( text = "Hello" )
run()

If I run it using python main.py, I correctly obtain this:

Now, if I pack it with packp3d -o app.p3d and run it with panda3d app.p3d I obtain this:

So, I can’t see the frame of the dialog. Am I missing something? Thanks!

I’m using Panda3D 1.7.2 on Maverick Meerkat 32.

Have you tried using “-r models” on the packp3d command-line?

It doesn’t work even with “-r models”. :frowning:

The symptom suggests that the file models/gui/dialog_box_gui.bam didn’t get packed into your p3d file. As rdb suggested, using -r models should ensure that the entire models tree gets packed into your p3d file, so if it still doesn’t work with that parameter, something is very strange.

What are the contents of your p3d file as revealed by the command “multify -tvf my.p3d”?

David

This is what I do:

$ cat main.py 
import direct.directbase.DirectStart 
from direct.gui.DirectDialog import OkDialog 
OkDialog( text = "Hello" ) 
run()
$ packp3d -r models -o my.p3d
:AppRunner: Total Panda3D disk space used: 154 MB
:AppRunner: Configured max usage is: 2048 MB
:Packager(warning): No such file: /home/flavio/Desktop/prova/p3d_info.xml
Generating my.p3d
$ multify -tvf my.p3d 
2 subfiles:
         303   29%   Jun 07 19:03 main.pyo
         368         Jun 07 19:03 p3d_info.xml
Last modification Jun 07 19:03

Oh, right–of course, “-r models” doesn’t actually copy the bam file into your p3d file; but it should ensure that it is properly downloaded and available to your p3d file when it executes. Hmm, let me try to reproduce this.

David

Thank you! I’ll file a bug report.

A strange (to me) aspect is that the package you pointed out doesn’t contain the file you cited (models/gui/dialog_box_gui.bam): I can’t find that file.

$ multify -tvf models.cmu_1.7.mf 
62 subfiles:
       10412          audio/sfx/GUI_click.wav
       11564          audio/sfx/GUI_rollover.wav
        2170          box.bam
        4295          camera.bam
       37137          cmr12.bam
       37331          cmss12.bam
       37331          cmtt12.bam
       61052          environment.bam
       30283          frowney.bam
        2216          gui/radio_button_gui.bam
       17880          jack.bam
     2033270          maps/4map.rgb
         315          maps/Dirlight.png
         315          maps/Pointlight.png
         315          maps/Spotlight.png
        5680          maps/circle.png
       33649          maps/cmr12.rgb
       35394          maps/cmss12.rgb
       36922          maps/cmtt12.rgb
       88312          maps/color-grid.rgb
       65272          maps/envir-bamboo.png
        1523          maps/envir-cylinder.png
        4688          maps/envir-ground.jpg
       14642          maps/envir-groundcover1.png
       48114          maps/envir-mountain1.png
      106434          maps/envir-mountain2.png
      133994          maps/envir-reeds.png
        6339          maps/envir-rock1.jpg
        7346          maps/envir-rock2.jpg
       84383          maps/envir-tree1.png
       65496          maps/envir-tree2.png
        6816          maps/envir-treetrunk.jpg
       15270          maps/frowney.rgb
       78272          maps/general_panel.rgba
       74384          maps/grid.rgb
      262656          maps/lightbulb.rgb
        3416          maps/lilsmiley.rgba
      197120          maps/noise.rgb
       89828          maps/panda-model.jpg
       43751          maps/panda_hat.rgb
      393728          maps/panda_head.rgb
       49451          maps/panda_torso.rgb
        3620          maps/panda_viser.rgb
       12800          maps/random.rgb
        3339          maps/shuttle_controls_1.rgb
       16704          maps/smiley.rgb
       66048          maps/soft_iris.rgb
        3733          misc/Dirlight.bam
        6168          misc/Pointlight.bam
        4178          misc/Spotlight.bam
        2207          misc/lilsmiley.bam
       18916          misc/smiley.bam
       77678          panda-model.bam
       27674          panda-walk.bam
       17429          panda-walk4.bam
      270402          panda.bam
      139176          ripple.bam
        6655          shuttle_controls.bam
       30403          smiley.bam
       40376          teapot.bam
       24627          yup-axis.bam
       24627          zup-axis.bam

Found the problem. I don’t build the pandatool tree as part of the rtdist build, so the flt2egg tool never gets built. Some models in the models tree are .flt, so they didn’t get included properly. I’ll fix it by simply enabling pandatool as part of the rtdist build.

For now, I advise manually calling flt2egg on the models that you need and including them yourself.

Ok, thank you so much!

Hi, I am having the problem in the OP even with the 1.8 models package (which contains gui/dialog_box_gui.bam, though). I have packed the file in the OP with:

$ packp3d -r models -o app.p3d

I don’t receive errors in the console or in the logs, but I can’t see the dialog box. Is my command correct? Am I missing anything? Thank you!

I’ve noticed that there is a different behavior if you try to reference models (from ‘models’ package) with or without the prefix ‘models/’ in a p3d or in a py file. If you consider the following code:

import direct.directbase.DirectStart
for a in [ 'models/gui/dialog_box_gui', 'gui/dialog_box_gui',
    'models/misc/fade', 'misc/fade' ]:
  np = loader.loadModel( a, okMissing = True )
  print 'referenced_by: %-25s path: %s' % (
    a, np.node().getFullpath().toOsSpecific() if np else 'not found' )
run()

It produces:

$ python main.py
[...]
referenced_by: models/gui/dialog_box_gui path: /Developer/Panda3D/models/gui/dialog_box_gui.egg
referenced_by: gui/dialog_box_gui        path: /Developer/Panda3D/models/gui/dialog_box_gui.egg
referenced_by: models/misc/fade          path: /Developer/Panda3D/models/misc/fade.egg
referenced_by: misc/fade                 path: /Developer/Panda3D/models/misc/fade.egg
[...]
$ packp3d -r models -o app.p3d
[...]
$ panda3d app.p3d
[...]
referenced_by: models/gui/dialog_box_gui path: not found
referenced_by: gui/dialog_box_gui        path: /Users/flavio/Library/Caches/Panda3D/hosts/runtime.panda3d.org_0f5faf88846080ae/models/cmu_1.8/gui/dialog_box_gui.bam
referenced_by: models/misc/fade          path: not found
referenced_by: misc/fade                 path: /Users/flavio/Library/Caches/Panda3D/hosts/runtime.panda3d.org_0f5faf88846080ae/models/cmu_1.8/misc/fade.bam

As you can see, files referenced without the prefix ‘models/’ are correctly loaded with the p3d or the py file, while the ones referenced with the prefix ‘models/’ work only with the py file.

Now, in Panda’s code the prefix ‘models/’ is used somewhere e.g.

direct/src/gui/DirectGuiGlobals.py:

defaultDialogGeom = loader.loadModel('models/gui/dialog_box_gui', okMissing = True)

direct/src/showbase/Transitions.py:

FadeModelName = "models/misc/fade"

I don’t know if the two things are related and if it may be the reason of the problem (maybe Panda’s code may be expected to behave differently than a generic p3d file).

It looks like that was the problem: the following code works using Python’s interpreter and Panda’s runtime too.

import direct.directbase.DirectStart 
from panda3d.core import Filename, VirtualFileSystem
from direct.gui.DirectDialog import OkDialog
if base.appRunner:
  modelsRoot = Filename.expandFrom( '$MODELS_ROOT' )
  vfs.mount( modelsRoot + '/models.cmu_1.8.mf', modelsRoot + '/models', VirtualFileSystem.MFReadOnly)
OkDialog( text = "Hello" ) 
run()

Is it the best way to use the ‘models’ package?

Well, you’ve got a workaround, but this does seem like a bug. Can you submit a bug report on the launchpad, please?

Thanks!
David

Ok, I’ve submitted it. :wink:

This problem is fixed in 1.9 now. Let me know if the fix should be retroactively applied to 1.8 as well.

There are additional optios to packp3d for more advanced usage. As with any Panda3D command-line application, you may specify “-h” on the command line to list the full set of available options.