GetReal returns 0.0
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 02/08/2012 at 03:53, xxxxxxxx wrote:
Hei guys,
Am I missing something damn obviously here? GetReal(self.EDT_MUL) seems to return 0.0 always.
Can somebody please enlighten me where the issue is? (Just copy&paste it into the script-manager)
Thanks,import c4d import c4d.modules.graphview as c4dgv class Dialog(c4d.gui.GeDialog) : EDT_MUL = 1000 BTN_OK = 2000 BTN_CN = 2001 def __init__(self) : super(Dialog, self).__init__() self.ok = False def CreateLayout(self) : self.GroupBegin(0, c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT) self.AddStaticText(0, c4d.BFH_LEFT, name="Multiplier") self.AddEditNumberArrows(self.EDT_MUL, c4d.BFH_SCALEFIT) self.AddButton(self.BTN_OK, c4d.BFH_SCALEFIT, name="Ok") self.AddButton(self.BTN_CN, c4d.BFH_SCALEFIT, name="Cancel") self.GroupEnd() return True def InitValues(self) : self.SetReal(self.EDT_MUL, 0.5, min=0, step=0.01) return True def Command(self, id, msg) : if id == self.BTN_OK: self.ok = True self.Close() elif id == self.BTN_CN: self.ok = False self.Close() return True def Open(self) : super(Dialog, self).Open(c4d.DLG_TYPE_MODAL, defaultw=200) def Succeeded(self) : return self.ok def GetResult(self) : return self.GetReal(self.EDT_MUL) def main() : dlg = Dialog() dlg.Open() if not dlg.Succeeded() : return mul = dlg.GetResult() print mul if __name__ == "__main__": main()
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 02/08/2012 at 03:57, xxxxxxxx wrote:
Ah, nevermind. That actually is obviously. One can't retrieve values after the dialog was closed.
import c4d class Dialog(c4d.gui.GeDialog) : EDT_MUL = 1000 BTN_OK = 2000 BTN_CN = 2001 def __init__(self) : super(Dialog, self).__init__() self.ok = False self.value = 0.5 def CreateLayout(self) : self.GroupBegin(0, c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT) self.AddStaticText(0, c4d.BFH_LEFT, name="Multiplier") self.AddEditNumberArrows(self.EDT_MUL, c4d.BFH_SCALEFIT) self.AddButton(self.BTN_OK, c4d.BFH_SCALEFIT, name="Ok") self.AddButton(self.BTN_CN, c4d.BFH_SCALEFIT, name="Cancel") self.GroupEnd() return True def InitValues(self) : self.SetReal(self.EDT_MUL, self.value, min=0, step=0.01) return True def Command(self, id, msg) : if id == self.EDT_MUL: self.value = self.GetReal(id) elif id == self.BTN_OK: self.ok = True self.Close() elif id == self.BTN_CN: self.ok = False self.Close() return True def Open(self) : super(Dialog, self).Open(c4d.DLG_TYPE_MODAL, defaultw=200) def Succeeded(self) : return self.ok def GetResult(self) : return self.value def main() : dlg = Dialog() dlg.Open() if not dlg.Succeeded() : return mul = dlg.GetResult() print mul if __name__ == "__main__": main()
Cheers,
-Nik