Hi,
I'm trying to create a pop-up menu with a modified layout. Currently, the default layout of c4d.gui.ShowPopupDialog
is vertical. I was looking forward to a columnar layout where its easier to see everything.
You can see an illustration of what I am after here:
https://www.dropbox.com/s/8dhs505yz34lap3/c4d140_modified_popup_menu.mp4?dl=0
A few notable behaviors are that
- modified columnar layout
- it disappears once you click a command (pop-up)
I initially thought the DLG_TYPE_ASYNC_POPUPEDIT
or DLG_TYPE_ASYNC_POPUP_RESIZEABLE
would do the trick but unfortunately, when you click a command, the dialog does not disappear.
You can see an illustration code below:
import c4d
import os
from c4d import gui, plugins, bitmaps, utils, documents
PLUGIN_ID = 1011325
MAIN_TAB = 10001
MY_BUTTON = 11002
class MyDialog(gui.GeDialog):
def get_all_objects(op):
output = []
while op:
output.append(op)
get_all_objects(op.GetDown())
op = op.GetNext()
return output
def CreateLayout(self):
self.GroupBegin(id=1013, flags=c4d.BFH_SCALEFIT, cols=5, rows=4)
self.AddButton(MY_BUTTON, c4d.BFV_MASK, initw=100, name="Button1")
self.AddButton(MY_BUTTON, c4d.BFV_MASK, initw=100, name="Button2")
self.AddButton(MY_BUTTON, c4d.BFV_MASK, initw=100, name="Button3")
self.AddButton(MY_BUTTON, c4d.BFV_MASK, initw=100, name="Button4")
self.AddButton(MY_BUTTON, c4d.BFV_MASK, initw=100, name="Button5")
self.AddButton(MY_BUTTON, c4d.BFV_MASK, initw=100, name="Button6")
self.GroupEnd()
return True
def Command(self, id, msg):
if (id == MY_BUTTON):
print "Button is clicked"
return True
return True
class MyMenuPlugin(plugins.CommandData):
dialog = None
def Execute(self, doc):
# create the dialog
if self.dialog is None:
self.dialog = MyDialog()
return self.dialog.Open(dlgtype=c4d.DLG_TYPE_ASYNC_POPUPEDIT, pluginid=PLUGIN_ID, defaultw=200, defaulth=150, xpos=-1, ypos=-1)
def RestoreLayout(self, sec_ref):
# manage the dialog
if self.dialog is None:
self.dialog = MyDialog()
return self.dialog.Restore(pluginid=PLUGIN_ID, secret=sec_ref)
if __name__ == "__main__":
okyn = plugins.RegisterCommandPlugin(PLUGIN_ID, "BT Popup",0, None, "Python Menu", MyMenuPlugin())
if (okyn):
print "Utilities Pop Up"
Thank you for looking at my problem