I was also talking about something like this. But it's not the best way to go. I suggest a TagData (plugin) with his own UI.
pyTagCode = '\
import c4d \n\
#Welcome to the world of Python \n\
\n\
def main():\n\
print "this ia a message"\n\
\n\
'
import c4d
# Main function
def main():
if op is None:
gui.MessageDialog("Please selecte a target object")
tag = c4d.BaseTag(c4d.Tpython)
tag[c4d.TPYTHON_CODE] = pyTagCode
op.InsertTag(tag)
c4d.EventAdd()
# Execute main()
if __name__=='__main__':
main()
By the way, don't forget you can save tag presets, that include python tags. You can simple add them with right click on your object in OM and "Load tag preset"
Cheers,
Manuel
Oh this is good to know! Thanks so much for the information, this is quite helpful!