insert_in_menu.py

insert_in_menu.py#

:insert_in_menu.py
insert_in_menu.py

Insert the command into the menu

1# The simplest program - just show the Hello world!
2import coat
3# add the translation of the identifier "test_script"
4coat.ui.addTranslation("test_script", "The example command")
5# if the command is not inserted in the file menu, we insert it there
6if not coat.ui.checkIfMenuItemInserted("test_script"):
7 coat.ui.insertInMenu("File","test_script","")
8 coat.dialog().text("The 'test_script' inserted into the File menu.").ok().show()
9else:
10 # ... if inserted, we execute the action
11 coat.dialog().text("Hello world!").ok().show()
:insert_in_menu.py
 1     # The simplest program - just show the Hello world!
 2     import coat
 3
 4     # add the translation of the identifier "test_script"
 5     coat.ui.addTranslation("test_script", "The example command")
 6
 7     # if the command is not inserted in the file menu, we insert it there
 8     if not coat.ui.checkIfMenuItemInserted("test_script"):
 9             coat.ui.insertInMenu("File","test_script","")
10             coat.dialog().text("The 'test_script' inserted into the File menu.").ok().show()
11     else:
12             # ... if inserted, we execute the action
13             coat.dialog().text("Hello world!").ok().show()