Bug in DirectDialog?

Hi all,

I think I found a bug in DirectDialog. Well, actually, its not really a bug, more a suggestion.
Would it be hard to have a possibility to have also extraArgs for the commands for the DirectDialog buttons?

Like, when I click No in my dialog, it will call the appropriate function, but will also pass extra arguments to that function? If I do right now “extraArgs=[arg,arg]” that is just ignored.

Thanks. :slight_smile:

this is my quick & dirty approach :

      dialog = YesNoDialog(dialogName='YesNoDialog1')
      YesBtn, NoBtn = dialog.__dict__['buttonList']
      YesBtn['command']=self.YesBtnClick
      YesBtn['extraArgs']=[dialog, 'Ok, Meneer']
      NoBtn['command']=self.NoBtnClick
      NoBtn['extraArgs']=[dialog, '1 dead "bug", pro-rsoft']

  def YesBtnClick(self,dialog,arg):
      print arg
      self.cleanUpDialog(dialog)

  def NoBtnClick(self,dialog,arg):
      print arg
      self.cleanUpDialog(dialog)

  def cleanUpDialog(self, dialog):
      dialog.cleanup()

Oops, you’re right, that is a bug. ynjh_jo’s workaround should be fine. Note that you can also use PythonUtil.Functor to bind extra args up with any function object:

from direct.showbase.PythonUtil import Functor
dialog = DirectDialog(..., command = Functor(self.myCallback, myArg1, myArg2))

David