Custom toolbar creation in HyperView

vipin_22401
vipin_22401 Altair Community Member
edited October 2020 in Community Q&A

Hi all,

Is it possible to create a custom toolbar in Hyperview?

I know it is possible in Hypermesh using the CreateMinibar command. I am looking for similar option in Hyperview.

Best Answer

  • tinh
    tinh Altair Community Member
    edited October 2020 Answer ✓

    Hi Vipin,

    there is a command can be used to make hyperview toolbar, '::hw::HwToolbar'

    but unlucky, it is not documented!

    outer wrapping command is ::hwtb::toolbar but it seems to be not completed (please check it with HW2020, i don't have this version)

     

    If aboves are not applicable, you can easily make your own toolbar, using ::hwtk::toolbutton to create toolbar buttons, and pack them in a frame, finally pack the frame (toolbar) on HV GUI

    Do not pack your own toolbar on HV dock frames because they are handled by HV GUI mechanism,

    pack your toolbar in HV center frame, example:

    proc mytoolbar {name items} { 	if {[regexp -nocase {^[a-z 0-9_]$} $name]} { 		return -code error "invalid toolbar name '$name'. Should contains only a-z, 0-9, _" 	} 	set tbw ._Tb_[string map {" " ""} $name] 	if {![winfo exists $tbw]} { 		frame $tbw 		pack $tbw {*}[pack info .mainFrame.center.f3.topMessageBar] -before .mainFrame.center.f3.topMessageBar 	} 	eval destroy [winfo child $tbw] 	pack [label $tbw.hdl -image classicToolbarHandleVertical.png -compound left] -side left -anchor w 	foreach item $items { 		::hwtk::[lindex $item 0] $tbw.item[incr i] {*}[lrange $item 1 end] 		pack $tbw.item$i -side left -anchor w 	} }  #example: foreach imageFile {entityElementsRigidSliding-24.png entityElementsRod-24.png entityElementsSpring-24.png entityElementsTetra4-24.png} { 	set imageFile [::hwt::CacheImage $imageFile] } proc action args {tk_messageBox -title "My Toolbar" -message $args} mytoolbar "New Toolbar" { {toolbutton -image entityElementsRigidSliding-24.png -command {action entityElementsRigidSliding-24.png}} {toolbutton -image entityElementsRod-24.png -command {action entityElementsRod-24.png}} {toolbutton -image entityElementsSpring-24.png -command {action entityElementsSpring-24.png}} {toolbutton -image entityElementsTetra4-24.png -command {action entityElementsTetra4-24.png}} }

     

    tested on HV 2019:

    image

     

Answers

  • Adriano Koga_20259
    Adriano Koga_20259 New Altair Community Member
    edited October 2020

    I'm not aware of such command for HM, but in the attached PDF you find some hints on creating a 'Preference' File that you could load into your HV session and add a custom menu like this:

    image

     

  • vipin_22401
    vipin_22401 Altair Community Member
    edited October 2020

    Hi @Adriano Koga 

    It doesn't exactly solve my issue, anyway thank you for sharing this document :)

  • tinh
    tinh Altair Community Member
    edited October 2020 Answer ✓

    Hi Vipin,

    there is a command can be used to make hyperview toolbar, '::hw::HwToolbar'

    but unlucky, it is not documented!

    outer wrapping command is ::hwtb::toolbar but it seems to be not completed (please check it with HW2020, i don't have this version)

     

    If aboves are not applicable, you can easily make your own toolbar, using ::hwtk::toolbutton to create toolbar buttons, and pack them in a frame, finally pack the frame (toolbar) on HV GUI

    Do not pack your own toolbar on HV dock frames because they are handled by HV GUI mechanism,

    pack your toolbar in HV center frame, example:

    proc mytoolbar {name items} { 	if {[regexp -nocase {^[a-z 0-9_]$} $name]} { 		return -code error "invalid toolbar name '$name'. Should contains only a-z, 0-9, _" 	} 	set tbw ._Tb_[string map {" " ""} $name] 	if {![winfo exists $tbw]} { 		frame $tbw 		pack $tbw {*}[pack info .mainFrame.center.f3.topMessageBar] -before .mainFrame.center.f3.topMessageBar 	} 	eval destroy [winfo child $tbw] 	pack [label $tbw.hdl -image classicToolbarHandleVertical.png -compound left] -side left -anchor w 	foreach item $items { 		::hwtk::[lindex $item 0] $tbw.item[incr i] {*}[lrange $item 1 end] 		pack $tbw.item$i -side left -anchor w 	} }  #example: foreach imageFile {entityElementsRigidSliding-24.png entityElementsRod-24.png entityElementsSpring-24.png entityElementsTetra4-24.png} { 	set imageFile [::hwt::CacheImage $imageFile] } proc action args {tk_messageBox -title "My Toolbar" -message $args} mytoolbar "New Toolbar" { {toolbutton -image entityElementsRigidSliding-24.png -command {action entityElementsRigidSliding-24.png}} {toolbutton -image entityElementsRod-24.png -command {action entityElementsRod-24.png}} {toolbutton -image entityElementsSpring-24.png -command {action entityElementsSpring-24.png}} {toolbutton -image entityElementsTetra4-24.png -command {action entityElementsTetra4-24.png}} }

     

    tested on HV 2019:

    image

     

  • vipin_22401
    vipin_22401 Altair Community Member
    edited October 2020
    tinh said:

    Hi Vipin,

    there is a command can be used to make hyperview toolbar, '::hw::HwToolbar'

    but unlucky, it is not documented!

    outer wrapping command is ::hwtb::toolbar but it seems to be not completed (please check it with HW2020, i don't have this version)

     

    If aboves are not applicable, you can easily make your own toolbar, using ::hwtk::toolbutton to create toolbar buttons, and pack them in a frame, finally pack the frame (toolbar) on HV GUI

    Do not pack your own toolbar on HV dock frames because they are handled by HV GUI mechanism,

    pack your toolbar in HV center frame, example:

    proc mytoolbar {name items} { 	if {[regexp -nocase {^[a-z 0-9_]$} $name]} { 		return -code error "invalid toolbar name '$name'. Should contains only a-z, 0-9, _" 	} 	set tbw ._Tb_[string map {" " ""} $name] 	if {![winfo exists $tbw]} { 		frame $tbw 		pack $tbw {*}[pack info .mainFrame.center.f3.topMessageBar] -before .mainFrame.center.f3.topMessageBar 	} 	eval destroy [winfo child $tbw] 	pack [label $tbw.hdl -image classicToolbarHandleVertical.png -compound left] -side left -anchor w 	foreach item $items { 		::hwtk::[lindex $item 0] $tbw.item[incr i] {*}[lrange $item 1 end] 		pack $tbw.item$i -side left -anchor w 	} }  #example: foreach imageFile {entityElementsRigidSliding-24.png entityElementsRod-24.png entityElementsSpring-24.png entityElementsTetra4-24.png} { 	set imageFile [::hwt::CacheImage $imageFile] } proc action args {tk_messageBox -title "My Toolbar" -message $args} mytoolbar "New Toolbar" { {toolbutton -image entityElementsRigidSliding-24.png -command {action entityElementsRigidSliding-24.png}} {toolbutton -image entityElementsRod-24.png -command {action entityElementsRod-24.png}} {toolbutton -image entityElementsSpring-24.png -command {action entityElementsSpring-24.png}} {toolbutton -image entityElementsTetra4-24.png -command {action entityElementsTetra4-24.png}} }

     

    tested on HV 2019:

    image

     

    Hi @tinh 

    I tried creating toolbar with '::hw::HwToolbar', but it is quite a difficult task to find the ::hw methods without any documentation.

    Your method works for me. Thank you!