GeDialog Timer Always Printing to Console?
-
Hey Folks,
Getting some odd behavior from a GeDialog's Timer and I've been troubleshooting this all day with no success. I thought it was due to a lot of different things, including some python libraries I had been using, but when I boiled it down to the most basic example and tried testing in a c4d without those libraries installed, I still get this very odd behavior of "(null)" being printed to the console over and over again if my Timer is active.If I uncomment the print("Timer") line it just prints "(null)Timer". The "(null)" calls always show up on the same line, unless I print from Timer(), then the print statement adds a new line break.
Issues are the same in 2023 and S26, whether I have the 3rd party python libraries installed or not. The following example is pure vanilla. No libs, just a boilerplate dialog that runs a timer and has 4 static text fields.
Thanks for your help!
import c4d from c4d import gui PLUGIN_ID = 1234567 # Replace with your unique plugin ID from PluginCafe class MyDialog(gui.GeDialog): ID_GROUP1 = 1000 ID_GROUP2 = 2000 ID_STATIC_TEXT1 = 1001 ID_STATIC_TEXT2 = 1002 ID_STATIC_TEXT3 = 2001 ID_STATIC_TEXT4 = 2002 def CreateLayout(self): self.SetTitle("My Custom GeDialog") # Group 1 if self.GroupBegin(self.ID_GROUP1, c4d.BFH_SCALEFIT, 2, 1, "Group 1"): self.AddStaticText(self.ID_STATIC_TEXT1, c4d.BFH_LEFT, name="Static Text 1") self.AddStaticText(self.ID_STATIC_TEXT2, c4d.BFH_LEFT, name="Static Text 2") self.GroupEnd() # Group 2 if self.GroupBegin(self.ID_GROUP2, c4d.BFH_SCALEFIT, 2, 1, "Group 2"): self.AddStaticText(self.ID_STATIC_TEXT3, c4d.BFH_LEFT, name="Static Text 3") self.AddStaticText(self.ID_STATIC_TEXT4, c4d.BFH_LEFT, name="Static Text 4") self.GroupEnd() return True def Timer(self, msg): print("Timer") return True def InitValues(self): self.SetTimer(100) print("InitValues") return True class MyCommandData(c4d.plugins.CommandData): dialog = None def Execute(self, doc): if self.dialog is None: self.dialog = MyDialog() return self.dialog.Open(dlgtype=c4d.DLG_TYPE_ASYNC, pluginid=PLUGIN_ID, defaultw=300, defaulth=150) def RestoreLayout(self, sec_ref): if self.dialog is None: self.dialog = MyDialog() return self.dialog.Restore(pluginid=PLUGIN_ID, secret=sec_ref) if __name__ == "__main__": c4d.plugins.RegisterCommandPlugin(PLUGIN_ID, "My Custom GeDialog", 0, None, "A custom GeDialog example", MyCommandData())
-
Well, that was a fast solution... couldn't it have emerged BEFORE I hit submit?!? Haha, the solution was easy... I was returning True on the Timer function. Took a look at the python memory viewer example and noticed they don't return a value on it. Removed the return from my Timer() function and all is working as expected.
def Timer(self, msg): print("Timer")
That's it:)