🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

How to customize pull down menu?

User: "Altair Forum User"
Altair Employee
Updated by Altair Forum User

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

Find more posts tagged with

Sort by:
1 - 11 of 111
    User: "Altair Forum User"
    Altair Employee
    OP
    Updated by Altair Forum User

    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

    User: "tinh"
    Altair Community Member
    Updated by tinh

    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

    User: "Altair Forum User"
    Altair Employee
    OP
    Updated by Altair Forum User

    Thanks for the reply!

    User: "Altair Forum User"
    Altair Employee
    OP
    Updated by Altair Forum User

    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

    User: "tinh"
    Altair Community Member
    Updated by tinh

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

    User: "Altair Forum User"
    Altair Employee
    OP
    Updated by Altair Forum User

    Yes, Thanks Mr Tinh

    User: "Jack LC_22402"
    Altair Community Member
    Updated by unknown

    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

    User: "tinh"
    Altair Community Member
    Updated by tinh

    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 }

     

     

    User: "Jack LC_22402"
    Altair Community Member
    Updated by unknown

    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

    User: "Altair Forum User"
    Altair Employee
    OP
    Updated by Altair Forum User

    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 ,

    User: "Altair Forum User"
    Altair Employee
    OP
    Updated by Altair Forum User

    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