How to customize pull down menu?

Altair Forum User
Altair Forum User
Altair Employee
edited October 2020 in Community Q&A

Add the following codes (change to your needs) into 'hmcustom.tcl' :


set mypath 'C:/Users/MYNAME/myscripts';

set top_menu [hm_framework getpulldowns]
catch {$top_menu delete [.hmMainMenuBar index 'MyMenu']}
catch {destroy $top_menu.custom}

menu $top_menu.custom -tearoff 0
$top_menu insert 20 cascade -label 'MyMenu' -menu $top_menu.custom

set cat1 $top_menu.custom
$cat1 add cascade -label 'Category 1' -underline 0 -menu [menu $cat1.mnu1 -title 'Cat-1']
$cat1.mnu1 add command -label 'Script 1' -command 'source {$mypath/script1.tcl}' -underline 0
$cat1.mnu1 add command -label 'Script 2' -command 'source {$mypath/script2.tcl}' -underline 0

$top_menu.custom add separator

set cat2 $top_menu.custom
$cat2 add cascade -label 'Category 2' -underline 0 -menu [menu $cat2.mnu2 -title 'Cat-2']
$cat2.mnu2 add command -label 'Script 21' -command 'source {$mypath/script21.tcl}' -underline 0
$cat2.mnu2 add command -label 'Script 22' -command 'source {$mypath/script22.tcl}' -underline 0

Start HM and you get your customized menus, see screenshot.

<?xml version="1.0" encoding="UTF-8"?>post-889-0-32501700-1416994162_thumb.png

Answers

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited January 2015

    Hello,

     

    First of all, great job, this topic is really useful! 

    I just have one question. How do I create a second level of cascade? I want that after 'Category 1' a new cascade appears with 'Category 1_1' and 'Category 1_2' and then I'll place my macros on those menus.

     

    Regards,

     

    Lawrence

  • tinh
    tinh Altair Community Member
    edited January 2015

    Hello,

     

    First of all, great job, this topic is really useful! 

    I just have one question. How do I create a second level of cascade? I want that after 'Category 1' a new cascade appears with 'Category 1_1' and 'Category 1_2' and then I'll place my macros on those menus.

     

    Regards,

     

    Lawrence

    Hi

    you can make sub-menu by pathname add cascade

    http://www.tcl.tk/man/tcl8.5/TkCmd/menu.htm#M26

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited January 2015

    Thanks for the reply!

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited March 2016

    I can not file location's hmcustom.tcl , Is this the same hmsettings.tcl and same location. When i add the codes, i can not see the new Menu also, But when i run the new codes. Its ok. But i can not use the sub-menu. and This sub-menu can use normally if i call direct

     

     

    <?xml version="1.0" encoding="UTF-8"?>2016-03-24_14-44-44.png

  • tinh
    tinh Altair Community Member
    edited March 2016

    it's in <altair_home>\hm\bin\winxx

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited March 2016

    Yes, Thanks Mr Tinh

  • Unknown
    edited August 2016

    Hello,

     

    thanks a lot for the topic, it's very useful! It works great the first time I open HM.

     

    However, I have a problem when I change the user profile (Preferences->User Profiles). If I change the profile, my menu disappears.

    I understood that, changing the profile, all the menus are reloaded and the hmcustom.tcl is loaded only the first time, but I didn't found a workaround to reload my menu.

     

    Thanks for any reply.

    Regards

  • tinh
    tinh Altair Community Member
    edited August 2016

    Hello,

     

    thanks a lot for the topic, it's very useful! It works great the first time I open HM.

     

    However, I have a problem when I change the user profile (Preferences->User Profiles). If I change the profile, my menu disappears.

    I understood that, changing the profile, all the menus are reloaded and the hmcustom.tcl is loaded only the first time, but I didn't found a workaround to reload my menu.

     

    Thanks for any reply.

    Regards

     

    B)/emoticons/default_cool.png' title='B)' />

    Hi,

    to reload hmcustom.tcl after userprofile changed, add below code to hmcustom.tcl:


     

     set ::hmcustomtclpath [info script] proc ::reloadhmcustomtcl args {      source $::hmcustomtclpath } if {[lsearch -exact [hm_framework getregisteredprocs after_userprofile] ::reloadhmcustomtcl]!=-1} {     hm_framework registerproc ::reloadhmcustomtcl after_userprofile }

     

     

  • Unknown
    edited August 2016

    Hi tinh,

     

    thanks, I appreciate a lot your valuable and fast reply.

     

    Your code works fine, I had just to replace !=1 with ==1 in the if condition.

     

    Thanks again!

    Regards

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited April 2019

    Add the following codes (change to your needs) into 'hmcustom.tcl' :

     

       set mypath 'C:/Users/MYNAME/myscripts';   set top_menu [hm_framework getpulldowns]  catch {$top_menu delete [.hmMainMenuBar index 'MyMenu']}  catch {destroy $top_menu.custom}   menu $top_menu.custom -tearoff 0  $top_menu insert 20 cascade -label 'MyMenu' -menu $top_menu.custom   set cat1 $top_menu.custom  $cat1 add cascade -label 'Category 1' -underline 0 -menu [menu $cat1.mnu1 -title 'Cat-1']  $cat1.mnu1 add command -label 'Script 1' -command 'source {$mypath/script1.tcl}' -underline 0  $cat1.mnu1 add command -label 'Script 2' -command 'source {$mypath/script2.tcl}' -underline 0   $top_menu.custom add separator   set cat2 $top_menu.custom  $cat2 add cascade -label 'Category 2' -underline 0 -menu [menu $cat2.mnu2 -title 'Cat-2']  $cat2.mnu2 add command -label 'Script 21' -command 'source {$mypath/script21.tcl}' -underline 0  $cat2.mnu2 add command -label 'Script 22' -command 'source {$mypath/script22.tcl}' -underline 0  

     

    Start HM and you get your customized menus, see screenshot.

     

     

    <?xml version="1.0" encoding="UTF-8"?>post-889-0-32501700-1416994162_thumb.png

     

    hello,

     i am new to this forum. please can you tell me how to use this option?

     

    thank you ,

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited July 2019

    I have run this script the option (my menu) is opening in hm but the script is not taking from 

     set mypath 'E:/vedio/scripts';

    and when I press the category 1. -tria per node.tcl it shows error (no such file or directory) like already showed in image.

    <?xml version="1.0" encoding="UTF-8"?>2016-03-24_14-44-44.png.d141f20a9e46e317b69ce71592747521.png