CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   ANSA (https://www.cfd-online.com/Forums/ansa/)
-   -   Variable from BCLineEditPathCreate (https://www.cfd-online.com/Forums/ansa/214800-variable-bclineeditpathcreate.html)

no_name18 February 13, 2019 10:22

Variable from BCLineEditPathCreate
 
Hi there,

I'm trying to create a toolbar in ANSA that will allow me to browse for a file, select it and store the absolute path of the selected file in a new variable when i close the toolbar.
How could i create the variable with the absolute path of the selected file? I tried using guitk.BCLineEditPathSelectedFilePaths but i always get the 'None' answer.

Thank you very much!:)

*The code i use can be found bellow.

import ansa
from ansa import guitk
from ansa import constants

def enterpressFunction(le, data):
print("Enter pressed")
return 0

def add_function_name():
CVals_13 = ["ansa"]
TopWindow = guitk.BCWindowCreate("EqStiffness", guitk.constants.BCOnExitDestroy)
Read_data = guitk.BCFrameCreate(TopWindow)
#Read file section
BCBoxLayout_1 = guitk.BCBoxLayoutCreate(Read_data, guitk.constants.BCHorizontal)
BCLineEditPath_1 = guitk.BCLineEditPathCreate(BCBoxLayout_1, guitk.constants.BCHistoryFiles, "", guitk.constants.BCHistorySelect, "")
##Parameters for the read file box layout
guitk.BCLineEditPathAddFilter(BCLineEditPath_1, "Punch File", CVals_13)
guitk.BCLineEditPathSetSelectionMode(BCLineEditPat h_1, guitk.constants.BCMulti)
guitk.BCLineEditPathSetDialogEnterEnabled(BCLineEd itPath_1, True)
guitk.BCLineEditPathSetEnterPressedFunction(BCLine EditPath_1, enterpressFunction, None)
print(guitk.BCLineEditPathSelectedFilePaths(BCLine EditPath_1))
guitk.BCShow(TopWindow)

add_function_name()


All times are GMT -4. The time now is 00:29.