community
cancel
Showing results for 
Search instead for 
Did you mean: 

Dev Space

Customize & extend the power of Alteryx. SDKs, APIs, custom tools, and more!

How to get and update field value on GUI from python backend ?

Atom

Hi.

May be someone help me with development custom alteryx tool on python.

Can't find how to change GUI values from python -(

 

Frontend:

    <section>
        <h2>1. Choice file</h2>
        <ayx aria-label="data-source-metainfo-filebrowse" data-ui-props='{type:"FileBrowse", widgetId:"dataSourceFilePath", fileTypeFilters: "Askia QES file|*.qes|Askia QEW file|*.qew|All Files|*.*", placeholder:"Select Askia file"}' data-item-props='{dataName: "browseFile", dataType:"SimpleString"}'></ayx>
    </section>

    <section>
        <h2>2. Choice tables and fields</h2>
        <ayx data-ui-props='{type:"ListBox", widgetId:"Tables", heightAuto: true}' data-item-props='{dataName: "tree"}'></ayx>
    </section>

Backend:

class AyxPlugin:
.....
    def pi_init(self, str_xml: str):
        """
        Handles extracting user-entered file name, and input data verification.
        Called when the Alteryx engine is ready to provide the tool configuration from the GUI.
        :param str_xml: The raw XML from the GUI.
        """

        # Getting the user-entered file name string from the GUI, and the output anchor from the XML file.
        self.file_path = Et.fromstring(str_xml).find('browseFile').text if 'browseFile' in str_xml else ''
        self.tables = Et.fromstring(str_xml).find('tablesList').text if 'tablesList' in str_xml else 'EMPTY'

self.tables is always EMPTY - it's incorrect
In str_xml also does not have any passed values.

Also can someone tell me how from python to change the value of the self.file_path on frontend ?

 

Thanks.

 

Moderator
Moderator

Hi @WarGot,

 

Thank you for posting.

 

On your example, you are trying to retrieve "tablesList" value where dataName is "tree".

 

    <ayx data-ui-props='{type:"ListBox", widgetId:"Tables", heightAuto: true}' data-item-props='{dataName: "tree"}'></ayx>

 

Could you please try with following line:

 

self.tables = Et.fromstring(str_xml).find('tree').text if 'tree' in str_xml else 'EMPTY'

 

Thanks,

 

PaulN