PySide6.QtWebEngineCore.QWebEngineFrame¶
- class QWebEngineFrame¶
- The - QWebEngineFrameclass gives information about and control over a page frame. More…- Added in version 6.8. - Synopsis¶- Properties¶- Methods¶- def - children()
- def - htmlName()
- def - isMainFrame()
- def - isValid()
- def - name()
- def - __ne__()
- def - __eq__()
- def - printToPdf()
- def - runJavaScript()
- def - size()
- def - url()
 - Note - This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE - Detailed Description¶- A web engine frame represents a single frame within a web page, such as those created by - <frame>or- <iframe>HTML elements. An active- QWebEnginePagehas one or more frames arranged in a tree structure. The top-level frame, the root of this tree, can be accessed through the mainFrame() method, and- children()provides a frame’s direct descendants.- A frame’s lifetime is, at most, as long as the - QWebEnginePageobject that produced it. However, frames may be created and deleted spontaneously and dynamically, for example through navigation and script execution. Because of this, many- QWebEngineFramemethods return optional values, which will be- std::nulloptif the frame no longer exists.- Note - Properties can be used directly when - from __feature__ import true_propertyis used or via accessor functions otherwise.- property htmlNameᅟ: str¶
 - Access functions:
 - property isMainFrameᅟ: bool¶
 - Access functions:
 - property isValidᅟ: bool¶
 - Access functions:
 - property nameᅟ: str¶
 - Access functions:
 - Access functions:
 - Access functions:
 - children()¶
- Return type:
- .list of QWebEngineFrame 
 
 - Returns a list of the frame’s children in an arbitrary order. - If the frame could not be found, returns an empty list. - htmlName()¶
- Return type:
- str 
 
 - Returns the value of the frame’s - nameHTML attribute, or an empty string if it has none.- If the frame could not be found, returns a null QString. - See also - Getter of property - htmlNameᅟ.- isMainFrame()¶
- Return type:
- bool 
 
 - Returns - trueif this object represents the page’s main frame;- falseotherwise.- Getter of property - isMainFrameᅟ.- isValid()¶
- Return type:
- bool 
 
 - Returns - trueif this object represents an existing frame;- falseotherwise.- Once a frame is invalid, it never becomes valid again. - Getter of property - isValidᅟ.- name()¶
- Return type:
- str 
 
 - Returns the frame name; that is, what would be returned by - window.namein JavaScript.- If the frame could not be found, returns a null QString. - See also - Getter of property - nameᅟ.- __ne__(rhs)¶
- Parameters:
- rhs – - QWebEngineFrame
- Return type:
- bool 
 
 - Returns - trueif- leftand- rightrepresent different frames in the same web page, otherwise- false.- __eq__(rhs)¶
- Parameters:
- rhs – - QWebEngineFrame
- Return type:
- bool 
 
 - Returns - trueif- leftand- rightrepresent the same frame in the same web page, otherwise- false.- printToPdf(resultCallback)¶
- Parameters:
- resultCallback – - PyCallable
 
 - Renders the current content of the frame into a PDF document and returns a byte array containing the PDF data as parameter to - resultCallback. Printing uses a page size of A4, portrait layout, and includes the full range of pages.- Note - The - QWebEnginePage.WebAction.Stopweb action can be used to interrupt this operation.- Note - We guarantee that the - resultCallbackis always called, but it might be done during page destruction. When- QWebEnginePageis deleted, the callback is triggered with an invalid value and it is not safe to use the corresponding- QWebEnginePage,- QWebEngineFrame, or- QWebEngineViewinstance inside it.- printToPdf(callback)
- Parameters:
- callback – - QJSValue
 
 - printToPdf(filePath)
- Parameters:
- filePath – str 
 
 - Renders the current content of the frame into a PDF document and saves it in the location specified in - filePath. Printing uses a page size of A4, portrait layout, and includes the full range of pages.- This method issues an asynchronous request for printing the web page into a PDF and returns immediately. To be informed about the result of the request, connect to the - pdfPrintingFinished()signal.- Note - The - Stopweb action can be used to interrupt this asynchronous operation.- If a file already exists at the provided file path, it will be overwritten. - See also - runJavaScript(scriptSource, resultCallback)¶
- Parameters:
- scriptSource – str 
- resultCallback – - PyCallable
 
 
 - runJavaScript(scriptSource, worldId[, resultCallback={}])
- Parameters:
- scriptSource – str 
- worldId – int 
- resultCallback – - PyCallable
 
 
 - Runs the JavaScript code contained in - scriptSourcescript on this frame, without checking whether the DOM of the page has been constructed.- To avoid conflicts with other scripts executed on the page, the world in which the script is run is specified by - worldId. The world ID values are the same as provided by- QWebEngineScript.ScriptWorldId, and between 0 and 256. If you leave out the world ID, the script is run in the- MainWorld(0).- When the script has been executed, the callable - resultCallbackis called with the result of the last executed statement.- Only plain data can be returned from JavaScript as the result value. - Note - Do not execute lengthy routines in the callback function, because it might block the rendering of the web engine page. - Note - We guarantee that the - resultCallbackis always called, but it might be done during page destruction. When- QWebEnginePageis deleted, the callback is triggered with an invalid value and it is not safe to use the corresponding- QWebEnginePage,- QWebEngineFrame, or- QWebEngineViewinstance inside it.- Returns the size of the frame within the viewport. - If the frame could not be found, returns QSizeF(). - Getter of property - sizeᅟ.- Returns the URL of the content currently loaded in this frame. - If the frame could not be found, returns an empty QUrl. - Getter of property - urlᅟ.