How to customize pull down menu?
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.
Answers
-
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
0 -
Altair Forum User said:
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
0 -
Thanks for the reply!
0 -
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
0 -
it's in <altair_home>\hm\bin\winxx
0 -
Yes, Thanks Mr Tinh
0 -
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
0 -
Altair Forum User said:
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
/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 }
0 -
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
0 -
Altair Forum User said:
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"?>
hello,
i am new to this forum. please can you tell me how to use this option?
thank you ,
0 -