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
Answers
-
Could you show a screenshot what you have currently and what you want?
0 -
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
0 -
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
0 -
Great!!
Thanks a lot tinh
0 -
Would you have any example or sample code where this type of GUI is implemented?
It would be a good start for me.
Thank you,
Jefferson
0 -
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
0 -
Thank you.
But actually this is more like a floating box, a pop-up.
Is there any way to build it in the HM interface just like the picture I showed before?
With a pop-up it would work the same way, but I just wanted to know if that is possible so it would be easier for the user.
Thanks,
Jefferson
0 -
Yes
Same codes as above and add these lines:
Wm forget $w
Hm_framework addpanel $w 'My Panel'
Hm_framework drawpanel 'My Panel'
0 -
Altair Forum User said:
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
0 -
Hi
Use
Set X [$w.f$i.ent get]
0 -
Altair Forum User said:
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.entL1pack $w.f2.labL1 -side left -anchor w
pack $w.f2.entL1 -padx 15 -pady 2 -side leftlabel $w.f2.labL2 -text 'L2 ='
entry $w.f2.entL2pack $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
0 -
You need this:
set w .lugType01
0 -
Altair Forum User said:
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.entL1pack $w.f2.labL1 -side left -anchor w
pack $w.f2.entL1 -padx 15 -pady 2 -side leftlabel $w.f2.labL2 -text 'L2 ='
entry $w.f2.entL2pack $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;
}#***********************************************************************************
0 -
Lack a space
Do your eyes have any problem? /emoticons/default_sleep.png' srcset='/emoticons/sleep@2x.png 2x' title='-_-' width='20' />
0 -
Thank you so much Mr. Tinh.. It worked~~~
0 -
Altair Forum User said:
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.
0 -
Ok, I just replaced 'My Panel' on the drawpanel line to $w and it worked fine.
Now I'm trying to have in my GUI something like showed below to select entities:
How can this be achieved?
Thank you
0 -
Hi
Use altair/.../hw/tcl/hw/collector/hwcollector.tcl
Reference help:
altair/.../hw/tcl/hw/collector/docs
But it looks a bit difference from native hm collectors, can you override
0 -
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?
0 -
Altair Forum User said:
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.
0 -
Hi
Use 'source' command to load it
0 -
Good, that woks.
Just not sure the format the callback must have.
How should it be defined to retrieve elements or components?
0 -
Read the html document in .../docs
The callback is to process events
When something happenning HM will call it with argument is event name
0 -
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
0 -
HmMarkTool is not useful, just to make example.
use *createmarkpanel to activate graphic selection.
0 -
And is there a way to suppress this command to change the framework? (Because it takes the user to another 'page' when this command is called)
Or just embed it within the Collector widget?
0 -
I looked for that way too but cannot
0 -
Ok, that's not too bad.
Thanks for your help tinh!!!
0 -
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!.
0