hi there,
i'm working on a command plugin with gedialog, that i want to dock in the layout.
one of the gui elements is AddCustomGui c4d.CUSTOMGUI_FILENAME.
the paths that are stored can be quite long.
the problem is, that the dialog wants to show the complete string, which makes the dialog extremely wide.
this only happens when the dialog is docked. then i can not scale the dialog smaller then the length of the string/filename.
if the dialog is not docked i can scale it smaller and the overflowing string is hidden.
sadly AddCustomGui has no properties initw and inith. i tried some combinations of flags but had no success.
am i missing something?
i could place the element in a scrollgroup, but then the "open document" button might be hidden in the part that is scrolled away.
any other options or workarouds?
cheers, sebastian
here is the code
import c4d, typing
ID_PLUGIN_CMD: int = 1025245
class MainDialog(c4d.gui.GeDialog):
ID_GRP_MAIN = 1000
ID_TEXT_1 = 1001
ID_TEXT_2 = 1002
extra_long_str = "this is some realy looooooooooooooooooooooooooooooooong text"
def __init__(self) -> None:
super().__init__()
def InitValues(self) -> bool:
return super().InitValues()
def CreateLayout(self) -> bool:
self.SetTitle("My Dialog")
self.GroupBegin(id=self.ID_GRP_MAIN, flags=c4d.BFH_SCALEFIT, cols=1)
self.GroupSpace(spacex=5, spacey=5)
self.GroupBegin(id=0, flags=c4d.BFH_SCALEFIT, cols=2)
self.AddStaticText(0, c4d.BFH_LEFT, name="path", initw=0 )
bc = c4d.BaseContainer()
self.AddCustomGui(self.ID_TEXT_1, c4d.CUSTOMGUI_FILENAME, '' ,c4d.BFH_SCALEFIT, 0, 0, bc,)
self.AddStaticText(0, c4d.BFH_LEFT, name="text", initw=0 )
self.AddEditText(self.ID_TEXT_2, c4d.BFH_FIT, 20,10 )
self.GroupEnd()
self.GroupEnd()
self.SetString( id=self.ID_TEXT_1, value=self.extra_long_str )
self.SetString( id=self.ID_TEXT_2, value=self.extra_long_str )
return super().CreateLayout()
def Command(self, cid: int, msg: c4d.BaseContainer) -> bool:
return super().Command(cid, msg)
class DialogManagerCommand (c4d.plugins.CommandData):
dialog: typing.Optional[MainDialog] = None
def Execute(self, doc: c4d.documents.BaseDocument) -> bool:
if self.dialog is None:
self.dialog = MainDialog()
if self.dialog.IsOpen() and not self.dialog.GetFolding():
self.dialog.SetFolding(True)
else:
self.dialog.Open(c4d.DLG_TYPE_ASYNC, ID_PLUGIN_CMD, -2, -2, defaultw=300, defaulth=200)
return True
def RestoreLayout(self, secret: any) -> bool:
if self.dialog is None:
self.dialog = MainDialog()
return self.dialog.Restore(ID_PLUGIN_CMD, secret)
def GetState(self, doc: c4d.documents.BaseDocument) -> int:
result: int = c4d.CMD_ENABLED
if self.dialog:
if self.dialog.IsOpen() and not self.dialog.GetFolding():
result |= c4d.CMD_VALUE
return result
def RegisterPlugin() -> bool:
return c4d.plugins.RegisterCommandPlugin(
id=ID_PLUGIN_CMD,
str="filename_test_01",
info=c4d.PLUGINFLAG_SMALLNODE,
icon=None,
help="",
dat=DialogManagerCommand())
def main():
if not RegisterPlugin():
raise RuntimeError( f"Failed to register {DialogManagerCommand} plugin." )
if __name__ == '__main__':
main()