<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>OK<br>
</p>
<p>Is it then possible I might have to write my own function to get
the values from the Qgis API?</p>
<p>I already have a Python script that runs in the main window
console that contains this code</p>
<p>layoutTitle = "Landscape 16:9 Header Nav Copyright Filename 2021"
<br>
<br>
project = QgsProject.instance() <br>
projectLayoutManager = project.layoutManager() <br>
layout = projectLayoutManager.layoutByName(layoutTitle) <br>
<br>
fileNameLabel = layout.itemById('Filename') <br>
fileNameText = fileNameLabel.text() <br>
</p>
<p>How would I adapt that to a custom function in the Function
Editor and assuming it is for the current layout.</p>
<p>Thanks<br>
</p>
<div class="moz-cite-prefix">On 4/08/21 11:44 pm, Stefan Giese
(WhereGroup) wrote:<br>
</div>
<blockquote type="cite"
cite="mid:47b4d295-f71e-703d-70bd-9b0de86d5971@wheregroup.com">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<p>Hi Patrick,</p>
<p>I think that you can not get the text from the label with the
item_variables function. The keys are limited to the predefinded
variables like:</p>
<p>_project_transform_context,item_id,item_uuid,layer_ids,layers,layout_dpi,layout_name,layout_numpages,layout_page,layout_pageheight,layout_pageoffsets,layout_pagewidth,miles_km,project_abstract,project_area_units,project_author,project_basename,project_creation_date,project_crs,project_crs_acronym,project_crs_definition,project_crs_description,project_crs_ellipsoid,project_crs_proj4,project_crs_wkt,project_distance_units,project_ellipsoid,project_filename,project_folder,project_home,project_identifier,project_keywords,project_last_saved,project_path,project_title,project_units,qgis_locale,qgis_os_name,qgis_platform,qgis_release_name,qgis_short_version,qgis_version,qgis_version_no,test,user_account_name,user_full_name</p>
<div class="moz-cite-prefix">But you can use your own variable
like filename and access it from anywhere:</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix"><img
src="cid:part1.EF39E973.F5C47A91@gmail.com" alt="" class=""></div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">Am 04.08.2021 um 13:27 schrieb
Patrick Dunford:<br>
</div>
<blockquote type="cite"
cite="mid:2838a2d8-a989-8cdb-fb8d-8753dcfa6ae2@gmail.com">
<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8">
<p>I'm looking through the documentation and there is this
example:</p>
<div class="section" id="layout-functions">
<h3><a class="toc-backref"
href="https://docs.qgis.org/3.10/en/docs/user_manual/working_with_vector/expression.html#id24"
moz-do-not-send="true"><span class="section-number">14.2.2.13.
</span>Layout Functions</a></h3>
<p>This group contains functions to manipulate print layout
items properties.</p>
<div class="wy-table-responsive">
<table class="colwidths-auto docutils align-default">
<thead> <tr class="row-odd">
<th class="head">
<p>Function</p>
</th>
<th class="head">
<p>Description</p>
</th>
</tr>
</thead> <tbody>
<tr class="row-even">
<td>
<p>item_variables</p>
</td>
<td>
<p>Returns a map of variables from a layout item
inside this print layout</p>
</td>
</tr>
</tbody>
</table>
</div>
<p><strong>An example:</strong></p>
<ul>
<li>
<p>Get the scale of the ‘Map 0’ in the current print
layout:</p>
<div class="highlight-default notranslate">
<div class="highlight">
<pre><span></span><span class="n">map_get</span><span class="p">(</span> <span class="n">item_variables</span><span class="p">(</span><span class="s1">'Map 0'</span><span class="p">),</span> <span class="s1">'map_scale'</span><span class="p">)</span>
</pre>
</div>
</div>
</li>
</ul>
</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">How do I find out how to get the
text value of the layout item "Filename" on the current print
layout? <br>
</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">On 4/08/21 2:40 pm, Patrick Dunford
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:a680851a-f408-d111-8ccc-ff6da5b33348@gmail.com">It
is just an ordinary text field on a composer layout I think. I
don't use the atlas functionality. <br>
<br>
On 4/08/21 10:19 am, Nyall Dawson wrote: <br>
<blockquote type="cite">On Wed, 4 Aug 2021 at 06:17, Patrick
Dunford <a class="moz-txt-link-rfc2396E"
href="mailto:enzedrailmaps@gmail.com"
moz-do-not-send="true"><enzedrailmaps@gmail.com></a>
wrote: <br>
<blockquote type="cite">Good day <br>
<br>
I am wishing to create a value in a field on a composer
layout that <br>
reads the value of another field on the layout and
calculates a value to <br>
be displayed. <br>
<br>
For example, I have an existing field called Filename on
the layout and <br>
in a python script running in the main window console, I
have this code <br>
that reads the value of the Filename field as follows: <br>
<br>
layoutTitle = "Landscape 16:9 Header Nav Copyright
Filename 2021" <br>
<br>
project = QgsProject.instance() <br>
projectLayoutManager = project.layoutManager() <br>
layout = projectLayoutManager.layoutByName(layoutTitle) <br>
<br>
fileNameLabel = layout.itemById('Filename') <br>
fileNameText = fileNameLabel.text() <br>
<br>
<br>
Obviously I am hoping that doing this from a field within
the layout <br>
that reads another field on the same layout will be much
simpler than <br>
the above. How exactly would I achieve that? <br>
</blockquote>
Just to clarify -- by "field" do you mean "a field value
from the <br>
atlas layer", or "a text label item"? <br>
<br>
Nyall <br>
</blockquote>
</blockquote>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
Qgis-user mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Qgis-user@lists.osgeo.org" moz-do-not-send="true">Qgis-user@lists.osgeo.org</a>
List info: <a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/qgis-user" moz-do-not-send="true">https://lists.osgeo.org/mailman/listinfo/qgis-user</a>
Unsubscribe: <a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/qgis-user" moz-do-not-send="true">https://lists.osgeo.org/mailman/listinfo/qgis-user</a>
</pre>
</blockquote>
<pre class="moz-signature" cols="72">--
Mit freundlichen Grüßen
Stefan Giese
Projektleiter/Consultant
************************************************************
Aufbau von Geodateninfrastrukturen mit Open-Source-Software
FOSS Academy 5 Tage-Kompaktkurs „Sommerschule 2021“
Jetzt anmelden: <a class="moz-txt-link-freetext" href="https://foss-academy.com/kompaktkurse/" moz-do-not-send="true">https://foss-academy.com/kompaktkurse/</a>
*************************************************************
WhereGroup GmbH
Schwimmbadstr. 2
79100 Freiburg
Germany
Fon: +49 (0)761 / 519 102 - 61
Fax: +49 (0)761 / 519 102 - 11
<a class="moz-txt-link-abbreviated" href="mailto:stefan.giese@wheregroup.com" moz-do-not-send="true">stefan.giese@wheregroup.com</a>
<a class="moz-txt-link-abbreviated" href="http://www.wheregroup.com" moz-do-not-send="true">www.wheregroup.com</a>
Geschäftsführer:
Olaf Knopp, Peter Stamm
Amtsgericht Bonn, HRB 9885</pre>
</blockquote>
</body>
</html>