[texworks] Scripts: Exploration of TW objects
Paul A Norman
paul.a.norman at gmail.com
Fri Nov 5 00:36:34 CET 2010
[ How does this sound? ]
So use via this sort of format ...(?)
To see the whole object tree,
Run this in the Qt Script Debugger Console prompt
qsdb> x =TW.target.findChildren();
And then look for "x" in the "Locals" pane in the debugger.
Only focus on things immediately below "x" that have a
"name="Something" for if it has no name. you probably will not find a
way of reliably addressing / accessing it.
You'll be able to read any of the actually used/available properties
and functions. You can check their details in the Qt objects functions
and properties on the Qt web site
In the Locals panel in the debugger. take note of the QtSomething name like:
QSplitterHandle(name = "qt_splithandle_") in the image above for item 103.
QSplitterHandle is what you would search for in the Qt documentation.
Keep an eye on Qt version number, 4.4 is probably safe for gerneal use
according to postings here, but if you know that your version of your
Tw release was built on a higher number of Qt, use that version's
documentation (check Tw's Help/About dialogue - for example my help
about says thta Tw 0.3 ver649 was built using Qt 4.6).
The higher Qt versions do introduce more functionality - but standard
Tw releases and distributions may, as of November 2010, only use 4.4.
On the web page use the menu at top once you've read a bit about
scripting and how it relates to this sort of tree ("x").
On 5 November 2010 08:53, Stefan Löffler <st.loeffler at gmail.com> wrote:
> Am 2010-11-04 10:52, schrieb Paul A Norman:
>> Put this (the below) as a script, I called it tw_OBJECTS.js in a script folder.
> this is very interesting, I didn't realize this. Thanks for sharing (it
> was the missing piece to get the poppler page number - see separate thread).
>> Does the result suggest that all the found children can in some way be
>> slotted into and even **safely** called by QtScript?
> If by "slot into" you refer to the signal/slot mechanism of Qt, the
> answer is pretty definitely no.
> Calling the objects' methods and/or accessing their properties shouldn't
> be a problem, though.
> A important thing to emphasize however: the output (i.e., the accessible
> objects) will depend on the context (TeXDocument vs. PDFDocument) the
> script is run in, in general (particular as far as ui items are concerned).
>> //Title: Experimental TW
>> //Description: Exploration of TW objects
>> //Author: Paul A. Norman
>> //Version: 0.3
>> //Date: 2010-11-04
>> //Script-Type: standalone
>> //Context: TeXDocument
>> //Shortcut: Alt+T, Alt+W
>> // TW.information(null, "", TW.app.findChildren());
>> study = TW.target.findChildren() +'';
>> study = study.replace(/,/g,",\n")
>> //========== Results ===========
More information about the texworks