Re-Initialize dialog if already opened
-
Hello,
When the dialog of my CommandData is already opened and I re-execute my CommandData the InitValues() function for example it executed only the first time dialog open.
To re-execute the InitValues() each time I execute my CommandData I added self.dialog.Close() before the self.dialog.Open() function.How can I do that without closing the dialog each time I execute my CommandData plugin?
class MyDlg(c4d.gui.GeDialog): def CreateLayout(self): ... def InitValues(self): Print("Hello World!") class MyCommandData(c4d.plugins.CommandData): dialog = None def Execute(self, doc): # Creates the dialog if its not already exists if self.dialog is None: self.dialog = MyDlg() # Close the dialog if its open self.dialog.Close() # Opens the dialog return self.dialog.Open(dlgtype=c4d.DLG_TYPE_ASYNC, pluginid=PLUGIN_ID, defaultw=500, defaulth=120, xpos=512, ypos=128)
-
hello,
for your next threads, please help us keeping things organised and clean. I know it's not your priority but it really simplify our work here.
and please, set the thread as solved once it is
you can simply check if your dialogbox is opened and call InitValues()
class MyDlg(c4d.gui.GeDialog): def CreateLayout(self): self.AddEditNumberArrows(1000,c4d.BFH_LEFT,70,10) return True def InitValues(self): self.SetFloat(1000, 1.0, min=0.0, step=0.1) print("Hello World!") return True class MyCommandData(c4d.plugins.CommandData): dialog = None def Execute(self, doc): # Creates the dialog if its not already exists if self.dialog is None: self.dialog = MyDlg() if self.dialog.IsOpen(): self.dialog.InitValues() return True # Opens the dialog return self.dialog.Open(dlgtype=c4d.DLG_TYPE_ASYNC, pluginid=PLUGIN_ID, defaultw=500, defaulth=120, xpos=512, ypos=128)
Cheers,
Manuel -
@m_magalhaes
Hello,
Right. Duly noted. Thanks for your time.