8.5.4.2. pymodaq_gui.parameter.ioxml module

pymodaq_gui.parameter.ioxml.XML_file_to_parameter(file_name)[source]

Convert a xml file into pyqtgraph parameter object.

Returns:

params – a list of dictionary defining a Parameter object and its children

Return type:

list

Examples

pymodaq_gui.parameter.ioxml.XML_string_to_parameter(xml_string)[source]

Convert a xml string into a list of dict for initialize pyqtgraph parameter object.

pymodaq_gui.parameter.ioxml.XML_string_to_pobject(xml_string)[source]

return a Parameter object from its deserialized version from a XML string

Deprecated as not symetric with parameter_to_xml_string

Parameters:

xml_string ((str) string representation of a Parameter Object)

Return type:

Parameter

pymodaq_gui.parameter.ioxml.add_text_to_elt(elt, param)[source]

Add a text filed in a xml element corresponding to the parameter value

Parameters:
  • elt (XML elt)

  • param (Parameter)

pymodaq_gui.parameter.ioxml.dict_from_param(param)[source]

Get Parameter properties as a dictionary

Parameters:

param (Parameter)

Returns:

opts

Return type:

dict

pymodaq_gui.parameter.ioxml.elt_to_dict(el)[source]

Convert xml element attributes to a dictionnary

Parameters:

el

pymodaq_gui.parameter.ioxml.parameter_to_xml_file(param, filename, overwrite=True)[source]

Convert the given parameter to XML element and update the given XML file.

Parameters

Type

Description

param

instance of pyqtgraph parameter

the parameter to be added

filename

string

the filename of the XML file

overwrite

boolean

raise Error is False and file exists

Examples

pymodaq_gui.parameter.ioxml.parameter_to_xml_string(param)[source]

Convert a Parameter to a XML string.

Parameters:

param (Parameter)

Returns:

str

Return type:

XMl string

Examples

>>> from pyqtgraph.parametertree import Parameter
>>>    #Create an instance of Parameter
>>> settings=Parameter(name='settings')
>>> converted_xml=parameter_to_xml_string(settings)
>>>    # The converted Parameter
>>> print(converted_xml)
b'<settings title="settings" type="None" />'
pymodaq_gui.parameter.ioxml.set_dict_from_el(el)[source]

8.5.4.2. Convert an element into a dict

el: xml element param_dict: dictionnary from which the parameter will be constructed

pymodaq_gui.parameter.ioxml.set_txt_from_elt(el, param_dict)[source]

get the value of the parameter from the text value of the xml element :type el: xml element :param el: :type el: xml element :type param_dict: dictionnary from which the parameter will be constructed :param param_dict: :type param_dict: dictionnary from which the parameter will be constructed

pymodaq_gui.parameter.ioxml.walk_parameters_to_xml(parent_elt=None, param=None)[source]

To convert a parameter object (and children) to xml data tree.

Parameters

Type

Description

parent_elt

XML element

the root element

param

instance of pyqtgraph parameter

Parameter object to be converted

Returns:

XML element – XML element with subelements from Parameter object

Return type:

parent_elt

pymodaq_gui.parameter.ioxml.walk_xml_to_parameter(params=[], XML_elt=None)[source]

To convert an XML element (and children) to list of dict enabling creation of parameter object.

Parameters

Type

Description

params

dictionnary list

the list to create parameter object

XML_elt

XML object

the XML object to be converted

Returns:

params – list of dict to create parameter object

Return type:

dictionnary list

Examples

>>> from pyqtgraph.parametertree import Parameter, ParameterItem
>>> import xml.etree.ElementTree as ET
>>> tree = ET.parse('text_bis.xml')
>>> root = tree.getroot()
>>> params=walk_xml_to_parameter(XML_elt=root)
>>> settings_xml=Parameter.create(name='Settings XML', type='group', children=params)
>>> settings=Parameter.create(name='Settings', type='group', children=params)
pymodaq_gui.parameter.ioxml.xml_file_to_parameter_dict(file_name)[source]
Return type:

dict

pymodaq_gui.parameter.ioxml.xml_string_to_parameter(xml_string)[source]
Return type:

Parameter

pymodaq_gui.parameter.ioxml.xml_string_to_parameter_dict(xml_string)[source]

Convert a xml string into a dict to initialize pyqtgraph parameter object.

Return type:

dict