GUI for HyperMesh Script
Hello all,
When I need to have user interaction with a script I'm working on, usually I use Tk to create the user interface,
I was wondering if there's a way to generate a GUI similar to what we see for common HM functions, where all the steps and required information are displayed at the same time.
How can that be achieved?
Thanks,
Jefferson
Find more posts tagged with
What I want is to have all the options and settings for the function being called to be selected and viewed all at once as any other HyperMesh function.
For example, the Automesh function displays this dashboard when selected:
<?xml version="1.0" encoding="UTF-8"?>
For now what I have is based basically on yes or no questions using the tk_messageBox function and some functions like hm_getfloat and createmarkpanel to get user input. But I would like to have something more visual and easy for the user to navigate through the options and different selections the function can offer.
<?xml version="1.0" encoding="UTF-8"?>
Can that be done? Or how could this workflow be improved?
Thanks,
Jefferson
Sure, that can.
you need to make a window (using command 'toplevel'), or a frame (using command 'frame')
create buttons (using command 'button'), entry box (using command 'entry'), other widgets like labels, menus, ...
and then bring them into the toplevel window (using command 'pack', or 'grid', or 'place')
many Tk commands help with building GUI you can refer here:
https://www.tcl.tk/man/tcl8.5/TkCmd/contents.htm
Hi
Set w .wDemo
Destroy $w
Toplevel $w
Wm transient $w .
For {set i 1} {$i<5} {incr i} {
Frame $w.f$i
Label $w.f$i.lbl -text 'Input $i ='
Entry $w.f$i.ent
Pack $w.f$i.lbl -side left -anchor w
Pack $w.f$i.ent -side right -anchor e
Pack $w.f$i -side top -anchor nw -fill x
}
Button $w.b -text Proceed
Pack $w.b -side top -anchor e
Hi
Set w .wDemo
Destroy $w
Toplevel $w
Wm transient $w .
For {set i 1} {$i<5} {incr i} {
Frame $w.f$i
Label $w.f$i.lbl -text 'Input $i ='
Entry $w.f$i.ent
Pack $w.f$i.lbl -side left -anchor w
Pack $w.f$i.ent -side right -anchor e
Pack $w.f$i -side top -anchor nw -fill x
}
Button $w.b -text Proceed
Pack $w.b -side top -anchor e
Hello Tinh ,
how i can i use the value of this 'Entry $w.f$i.ent' for making node coordinate in Hypermesh.
Thanking You
Hi
Use
Set X [$w.f$i.ent get]
Thank You for your reply Mr. Tinh
in my tcl program i used a procedure for entry as shown below.
#***********************************************************************************
proc ::Execlug01LUG {args} {
set w .lugType01
destroy $w
toplevel $w
wm transient $w .
frame $w.f2
#---------------------------------------
label $w.f2.labL1 -text 'L1 ='
entry $w.f2.entL1
pack $w.f2.labL1 -side left -anchor w
pack $w.f2.entL1 -padx 15 -pady 2 -side left
label $w.f2.labL2 -text 'L2 ='
entry $w.f2.entL2
pack $w.f2.labL2 -side left -anchor w
pack $w.f2.entL2 -padx 15 -pady 2 -side left
pack $w.f2 -side top -anchor nw -fill x
#---------------------------------------
button $w.b -text Model -font {Helvetica -25 bold} -height 1 -width 10 -background gray75 -foreground blue -command {hm_setpanelproc ::modelclick}
pack $w.b -side top -anchor nw -fill x
}
proc ::modelclick {args} {
set l1 [$w.f2.entL1 get]
set l2 [$w.f2.entL2 get]
*createnode 0 0 0 0 0 0;
*createnode l2 0 0 0 0 0;
*createnode l2 l1 0 0 0 0;
*createnode 0 l1 0 0 0 0;
}
#***********************************************************************************
In this case i am not able to get the value of l1 and l2 to create the nodes. please help me
Thank You
You need this:
set w .lugType01
Thank You for your reply Mr. Tinh
but still getting error 'can't read 'w.lugType01': no such variable' when i run the following tcl file in hypermesh
#***********************************************************************************
proc ::Execlug01LUG {args} {
set w .lugType01
destroy $w
toplevel $w
wm transient $w .
frame $w.f2
#---------------------------------------
label $w.f2.labL1 -text 'L1 ='
entry $w.f2.entL1
pack $w.f2.labL1 -side left -anchor w
pack $w.f2.entL1 -padx 15 -pady 2 -side left
label $w.f2.labL2 -text 'L2 ='
entry $w.f2.entL2
pack $w.f2.labL2 -side left -anchor w
pack $w.f2.entL2 -padx 15 -pady 2 -side left
pack $w.f2 -side top -anchor nw -fill x
#---------------------------------------
button $w.b -text Model -font {Helvetica -25 bold} -height 1 -width 10 -background gray75 -foreground blue -command {hm_setpanelproc ::modelclick}
pack $w.b -side top -anchor nw -fill x
}
proc ::modelclick {args} {
set w.lugType01
set l1 [$w.f2.entL1 get]
set l2 [$w.f2.entL2 get]
*createnode 0 0 0 0 0 0;
*createnode l2 0 0 0 0 0;
*createnode l2 l1 0 0 0 0;
*createnode 0 l1 0 0 0 0;
}
#***********************************************************************************
Yes
Same codes as above and add these lines:
Wm forget $w
Hm_framework addpanel $w 'My Panel'
Hm_framework drawpanel 'My Panel'
Hi tihn,
With this addition I keep getting the following error:
My Panel does not exist. while executing 'error '$frame does not exist.'' ('drawpanel' arm line 11)
I'm sorry for so newbie question, but I'm struggling a little to work with GUI.
Thanks for you answer tinh.
However I'm not clear how this should be handled to use in one of my codes.
Should I use exec to call the file or something else?
Hey @tinh, can you help me with that?
Thank you.
I've been playing around with this collector, but I still didn't get to do what I intend. Right now when I use HmMarkTool or HmEntSelCol I can only select the entities one by one, e.g. I cannot create a bounding box in the UI to select the entities inside the box. How can this be achieved?
I also found this UI manager called Process Studio and I've been trying to make something work from that.
If I add a collector from that and export a TCL code, I can see the script created to generate that collector, however I'm not being able to run it properly.
So I have the following process on the script:
::hw::pmgr::${::hw::pmgr::namespace}::DisplayWnd
::hw::pmgr::${::hw::pmgr::namespace}::Exec
::hw::pmgr::${::hw::pmgr::namespace}::SetDataInDataModel
::hw::pmgr::${::hw::pmgr::namespace}::GetDataFromDataModel
::hw::pmgr::${::hw::pmgr::namespace}::OnDataModelChanged
From that, what do I need to define in order to get this working?
Also, what do I need to define in terms of 'hw::pmgr::namespace'?
Thank you
Actually I found a command to activate graphic selection in multiple mode: hmcollector
But cannot retrieve selected entities by hm_getmark, even worse that it hanges from HM17, so the command seems to be developing...
Cannot hide panel pops up by *createmarkpanel, it will activate 'function_lock' mode (prevents any panel posten onto it)
Hope someone find a way.
In hwcollector.tcl, it says user must develop the callback using some C headers not provided in hw installation!.
Could you show a screenshot what you have currently and what you want?