Hi Elisabeth,
I guess my recommendation is to structure your code like an extension, so that Chimera will execute a ChimeraExtension.py file at startup that you've written.  Normally, you put code into a ChimeraExtension.py file to do all the stuff to get your extension into the Tools menu, add a command version, etc.. but the code in that file can actually be almost anything.  Just put your code to add your top-level menu in there instead of normal extension-adding code.
Let me know if you need more details.

--Eric

On Jan 21, 2011, at 10:58 AM, Elisabeth Ortega wrote:

Hi Eric,
 
I'm testing the two options. Your option works only when I execute  ">>chimera mymenu.py" .How can I auto-execute your code when I start Chimera?

Thanks

2011/1/21 Eric Pettersen <pett@cgl.ucsf.edu>
Hi Elisabeth,
As Tom says, the code he refers to is really more complex than you need.  Just do this:

from chimera.tkgui import addMenu
myMenu = addMenu(label="menu name")

to create a top-level menu that you can add items to.  An example of its use in Chimera itself is in the _getAliasMenu() function in Midas/midas_text.py.

--Eric

                        Eric Pettersen
                        UCSF Computer Graphics Lab
     &nbsp p;            http://www.cgl.ucsf.edu

On Jan 21, 2011, at 9:20 AM, Tom Goddard wrote:

 Hi Elisabeth,

  There is some code in Chimera that makes a new top-level menu called
Volume that is a copy of the Tools / Volume Data submenu.  That Volume
menu is displayed using menu entry Tools / Volume Data / Volume Menu on
Menubar and if you show it it is remembered in the Chimera preferences
file so it will appear every time you run Chimera.  This is a more
complex than you need.  But the main routine that would be useful to
study is called create_toplevel_volume_menu() in file

    chimera / share / VolumeMenu / __init__.py

in your Chimera distribution.  It would be easy to make a similar
Ch a toplevel Scripts menu and simply read all
the files in one of your directories and made menu entries which caused
the file to be opened in Chimera.  If you need more help with writing it
ask.

    Tom


Dear Chimera Dev Team,


I'm trying to put other option in the menu bar (File, Select, Actions,
... , myOption, Help) to store my own scripts. I'm doing a deep search
on your python and C++ codes but I don't find which is the code that I
have to modify.
I know that is easy to store my scripts in the Tools menu, but I
prefer to put my scripts in a new option of the menu bar.


Thanks a lot for taking the time to reply.



Elisabeth Ortega
Autonomous University of Barcelona (UAB)

_______________________________________________
Chimera-dev mailing list
Chimera-dev@cgl.ucsf.edu
http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-dev