On 30/03/2014 at 07:38, xxxxxxxx wrote:
I have this commandplugin with a "dynamic" dialog.
I use LayoutFlushGroup(id) and GeDialog.LayoutChanged(id) to create and remove groups in the dialog.
That is working as expected.
However, I would like to resize the dialog, so that it fits all fields.
Now when removing a field, there is an empty space.
I know I can rebuild the whole dialog, but I would think that flushing only one field and then resize should be enough?
I have seen the post "Topic: Controlling the window size of a gui" covering this question, but I cannot get it to work.**
import c4d
from c4d import gui, plugins, bitmaps
import os
PLUGIN_ID = 1031945 # Plugin ID
class ALDIDialog(gui.GeDialog) :
def __init__(self, host, width) :
self.host = host
self.width = width
def CreateLayout(self) :
self.AddEditNumber(1000, c4d.BFH_SCALEFIT)
self.GroupBegin(1001, c4d.BFH_LEFT)
self.AddButton(1002, c4d.BFH_SCALEFIT, name = 'Reopen')
self.AddButton(1003, c4d.BFH_SCALEFIT, name = 'Close')
self.GroupEnd()
return True
def InitValues(self) :
self.SetLong(1000, self.width, 0, step=1)
return True
def Command(self, id, msg) :
if id == 1002: self.host.ReOpen(self.GetLong(1000))
if id == 1003: self.Close()
return True
class MyMenuPlugin(plugins.CommandData) :
def Execute(self, doc) :
# create the dialogs
self.dialoog = ALDIDialog(self, 200)
return self.dialoog.Open(dlgtype=c4d.DLG_TYPE_ASYNC, xpos = 150, ypos = 150, defaultw = 200)
def ReOpen(self, width) :
if self.dialoog.Close() :
self.dialoog = ALDIDialog(self, width)
return self.dialoog.Open(dlgtype=c4d.DLG_TYPE_ASYNC, xpos = 150, ypos = 150, defaultw = width)
if __name__ == "__main__":
bmp = bitmaps.BaseBitmap()
dir, file = os.path.split(__file__)
fn = os.path.join(dir, "res", "aldi.png")
bmp.InitWith(fn)
okyn = plugins.RegisterCommandPlugin(PLUGIN_ID, "re-open",0, bmp, "re-open", MyMenuPlugin())
if (okyn) :
print "re-open initialized."
else: print "Error initializing re-open"
I also noticed that when you manually resize a dialog, that is being stored by cinema.
The next time you startup the dialog, the last stored size is used.
How is that done?
Edit: Added link to topic