This is one SOLUTION of the problem:
// List all objects in the scene
$allObjects = `ls -g`;
optionMenuGrp -label "Objects";
for ($tempName in $allObjects)
menuItem -label $tempName;
It seemed to work for me, thanks for help. If anyone knows how to select an object in the scene depending on which one is selected from this please write a post. I think I will have to use the select command in combination with the changeCommand flag for the optionMenuGrp, but I am not sure.