How to get selection value by using hwtk::openfileentry?

User: "Bhavik Sheth_21143"
Altair Community Member
Updated by Bhavik Sheth_21143

Hello,

I am using the hwtk::openfileentry function to select a file.

After required file selection, I want to perform some action.

If a user selects a zd3plot file then I want to load that file in hyperview session.

However, I am struggling to get the selection value from a widget. 

As an example shown in the image, I have selected one text file. So how to get the complete selection path.

 

Find more posts tagged with

Sort by:
1 - 1 of 11
    User: "Fred_Juras"
    Altair Employee
    Accepted Answer
    Updated by Fred_Juras

    Hi,

    There are two ways to retrieve value from a tk widget:
    - using the widget command 'get'
    - saving the path into a variable with the -textvariable option

    Please find below an example:

    ::hwtk::dialog .d -title "TEST" -x 600 -y 300 
    set test [.d recess]
    hwtk::openfileentry $test.fe1 -multiple false -textvariable fileentry -help "Select report file"
    grid $test.fe1 -row 1 -col 1 -sticky e -pady 2
    .d configure -destroyonunpost 0
    .d post
    puts $fileentry
    $test.fe1 get

    Please first provide a file in the file entry before executing the two last commands: puts $fileentry and $test.fe1 get.

    FYI: I recommend saving the path into a variable solution. Because, by default a tk window is destroyed when you close it. Thus the widget command 'get' gives error if you close and destroy the window. Unless you ask to not destroy te window when you close it with the configure -destroyonunpost 0 command.