GeDialog in a Python Script does not work
-
Hello,
I'm probably missing something here, but I can't get a GeDialog in a Python Script (not plugin!) to work at all.
import c4d class TestDialog(c4d.gui.GeDialog): BUTTON_ID = 1001 def CreateLayout(self): self.SetTitle("A meaningful dialog title") self.AddButton(self.BUTTON_ID, c4d.BFH_SCALE|c4d.BFV_SCALE, 100, 25, "Close Dialog") #self.AddDlgGroup(c4d.DLG_OK|c4d.DLG_CANCEL) return True def Message(self, msg, result): return True def Command(self, id, msg): if id==self.BUTTON_ID: self.Close() return True # Main function def main(): # Test dialog diag = TestDialog() diag.Open(dlgtype=c4d.DLG_TYPE_MODAL, defaultw=400, defaulth=400) # Execute main() if __name__=='__main__': main()
The only thing that happens when executing this script is that an empty dialog appears (the size is correct, but there is neither a dialog title, nor any gadgets) that can only be closed by force-quitting Cinema.
- The console does not show any errors or exceptions.
- I tested the same code in R20 and R19, both with the exact same result.
- Manually calling
diag.CreateLayout()
before thediag.Open()
call did not change anything.
What am I doing wrong?
Cheers,
Frank -
Hi Frank, you actually return True from the Message method while the result of the parent call was expected
def Message(self, msg, result): return c4d.gui.GeDialog.Message(self, msg, result)
For more information please read the documentation about GeDialog.Message.
Cheers,
Maxime. -
Aaah, ok, thanks!
I browsed a couple of examples here in the forum, and always saw them return True. Should've known better
Cheers,
Frank