<div dir="ltr">I've solved many similar problems by parsing the document's .sla file (which is just XML), when the Scripter API doesn't quite do what you need.<div><br></div><div>Here's the basic gist to get the page number for a frame named "foo":</div><div><br></div><div><p style="margin:0px;white-space:pre-wrap">import xml.etree.ElementTree as ET<br>tree = ET.parse(getDocName())<br>root = tree.getroot()<br>frame = "foo"<br>element = root.find(f'./DOCUMENT/PAGEOBJECT[@ANNAME="{frame}"]')<br>page_number = element.get("OwnPage")<br></p><p style="margin:0px;white-space:pre-wrap"><br></p><p style="margin:0px;white-space:pre-wrap">For this to work, the object has to manually have been given a name, not just leaving the auto-generated one, otherwise it's not stored in the .sla file.</p></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 14 Apr 2022 at 00:43, Matt Miller <<a href="mailto:matt.miller@fastmail.com">matt.miller@fastmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">From Python I want to find the page number that contains a certain text frame. I know the object name of the frame I'm looking for, but I don't know what page it's on. The only way I've thought of is to loop page-by-page over the document, and for each page use getAllObjects() to see if the frame is on that page. The documents are typically hundreds or even a couple thousand pages. I'm hoping for a faster way.<br>
<br>
From the GUI I see that if I click on an object to select it, then the page returned by currentPage() is what I'm looking for, but if I just call selectObject() then currentPage() doesn't seem to care.<br>
<br>
Thanks.<br>
<br>
<br>
--<br>
<br>
  Matt Miller<br>
  mailto:<a href="mailto:matt.miller@fastmail.com" target="_blank">matt.miller@fastmail.com</a><br>
<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="http://lists.scribus.net/pipermail/scribus/attachments/20220413/a7f1d8c6/attachment.htm" rel="noreferrer" target="_blank">http://lists.scribus.net/pipermail/scribus/attachments/20220413/a7f1d8c6/attachment.htm</a>><br>
___<br>
Scribus Mailing List: <a href="mailto:scribus@lists.scribus.net" target="_blank">scribus@lists.scribus.net</a><br>
Edit your options or unsubscribe:<br>
<a href="http://lists.scribus.net/mailman/listinfo/scribus" rel="noreferrer" target="_blank">http://lists.scribus.net/mailman/listinfo/scribus</a><br>
See also:<br>
<a href="http://wiki.scribus.net" rel="noreferrer" target="_blank">http://wiki.scribus.net</a><br>
<a href="http://forums.scribus.net" rel="noreferrer" target="_blank">http://forums.scribus.net</a><br>
</blockquote></div>