THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 25/10/2012 at 03:30, xxxxxxxx wrote:
Originally posted by xxxxxxxx
Ok, clear.
Do you have an example of such a popup menu?
Sorry, I see you just told me
"unfortunately it's not possible to develop custom GUIs with the Python SDK, only in C++."
No, I just said that we can't build custom gadgets in Python but we can of course create dynamic popup menus.
Here's an example of a recursive popup dialog:
import c4d
from c4d import gui
def BuildMenuRecursive(menu, level, maxlevel) :
offset = 10*level
menu.SetString(c4d.FIRST_POPUP_ID+offset, 'Item '+str(offset+1))
menu.SetString(c4d.FIRST_POPUP_ID+offset+1, 'Item '+str(offset+2))
level += 1
if level==maxlevel:
menu.SetString(c4d.FIRST_POPUP_ID+offset+2, 'Item '+str(offset+3))
else:
submenu = c4d.BaseContainer()
submenu.SetString(1, 'Item '+str(offset+3))
BuildMenuRecursive(submenu, level, maxlevel)
menu.SetContainer(c4d.FIRST_POPUP_ID+offset+2, submenu)
menu.SetString(c4d.FIRST_POPUP_ID+offset+3, 'Item '+str(offset+4))
# Build main menu recursively
# With a maximum of 5 menus
menu = c4d.BaseContainer()
BuildMenuRecursive(menu, 0, 5)
# Show popup dialog
result = gui.ShowPopupDialog(cd=None, bc=menu, x=300, y=300)
print result