Hello,
In a previous post, How to open a GeDialog Modal to default width & height? the solution to the defaultw
/defaulth
bug for a script Modal was to pass the pluginid
. I am trying this solution with a Command Plugin and I'm not getting the specified sizes for either window. I thought maybe it has to do with the subid
but my Main Dialog isn't behaving either.
Here is some test code I'm using:
import c4d
from c4d import documents, gui, plugins
PLUGIN_ID = 1055306 #test id
ANOTHER_DLG_ID = 5000
class AnotherDlg(gui.GeDialog):
MY_TEXT = 1000
def CreateLayout(self):
self.SetTitle("Another Dialogue")
self.AddStaticText(self.MY_TEXT, c4d.BFH_CENTER | c4d.BFH_SCALE,
name="Another Dialog",inith=40)
return True
class MyDlg(gui.GeDialog):
MY_BUTTON = 1000
def __init__(self):
global anotherDialog
self.anotherDialog = AnotherDlg()
def CreateLayout(self):
self.SetTitle("Test")
self.AddButton(self.MY_BUTTON, c4d.BFH_CENTER | c4d.BFH_SCALE | c4d.BFV_CENTER | c4d.BFV_SCALE, initw=0, inith=0, name="Open Dialog")
return True
def Command(self, id, msg):
if id == self.MY_BUTTON:
self.anotherDialog.Open(c4d.DLG_TYPE_MODAL, pluginid=PLUGIN_ID, subid=ANOTHER_DLG_ID, xpos=-2, ypos=-2, defaultw=600, defaulth=150)
return True
def Restore(self, pluginid, secref):
if secref['subid'] == ANOTHER_DLG_ID:
return self.anotherDialog.Restore(pluginid, secref)
else:
return super(MyDlg, self).Restore(pluginid, secref)
class MyData(c4d.plugins.CommandData):
dialog = None
def Execute(self, doc):
if self.dialog is None:
self.dialog = MyDlg()
global myDlg
myDlg = self.dialog
return myDlg.Open(dlgtype=c4d.DLG_TYPE_ASYNC, xpos=-2, ypos=-2,
pluginid=PLUGIN_ID, defaultw=700, defaulth=300)
def RestoreLayout(self, sec_ref):
if self.dialog is None:
self.dialog = MyDlg()
global myDlg
myDlg = self.dialog
return myDlg.Restore(pluginid=PLUGIN_ID, secref=sec_ref)
if __name__ == "__main__":
plugins.RegisterCommandPlugin(id=PLUGIN_ID,
str="Test",
info=0,
help="Test",
dat=MyData(),
icon=None)
Here are the results:
The Main Dialog (DLG_TYPE_ASYNC
) is 324x51 and the secondary dialog (DLG_TYPE_MODAL
) is 324x100. This is making layout difficult.
Can anyone please help me to get these to open to the specified sizes? Thank you!