current position:Home>Webengine loading local html is invalid, and html is the dynamic address generated by JS, which can be solved

Webengine loading local html is invalid, and html is the dynamic address generated by JS, which can be solved

2022-04-29 12:37:23CSDN Q & A

The phenomenon and background of the problem

Realize the demand : Will local html File by webengine Output on software ( Software means pyqt5-designer Designed pages , Just learned don't know how to say don't spray )
platform MacOS and win Both platforms have tried , direct load(‘svgaPage.html’) None of the local files are valid
I dare not say the whole network , At least it's stuck 3 God , No less than 1000 A solution , Still not solved ( There may be a solution, but I don't understand , So it's troublesome to post specially )

After testing, the local html Open it with a browser , Copy the address in the browser to be effective , Can successfully output ; Prove that the source code is OK ; But the actual situation is that the address is dynamic after packaging , It's the tail ?html=1x3jk Such , Randomly generated ; So I can't use it correctly .

My guess is webengine There is no call JS, But for beginners, one , I'm not sure , I've been searching like a headless fly for a long time .

structure : All in the root directory

【svgaPage.html】

<html>        <script src="https://cdn.jsdelivr.net/npm/[email protected]/build/svga.min.js"></script>        <script src="//s1.yy.com/ued_web_static/lib/jszip/3.1.4/??jszip.min.js,jszip-utils.min.js" charset="utf-8"></script>        <script src="./SVGAPlayer/build/svga.min.js">import SVGA from 'svgaplayerweb'</script>        <div id="demoCanvas" style="width: 100%;height: 100%;background-color: chartreuse"></div>                <script> var player = new SVGA.Player('#demoCanvas'); var parser = new SVGA.Parser('#demoCanvas'); //  If you need support  IE6+, Then you must pass the same selector to  Parser. parser.load('./fansCrad/fans.svga', function(videoItem) { // Here we begin to control  player.loops = 1; // cycles  player.clearsAfterStop = true; // Whether to clear the content after playing  player.setVideoItem(videoItem); // Need to get load Return parameters to take effect ( I don't know what it means for the moment ) player.startAnimation(); // Start playing  // player.pauseAnimation();  Pause play  // player.stopAnimation();  Stop playing  // player.onFrame();  What frame is currently playing , Adjust according to business  }) </script>        </html>

【main.py】

    def showSvga(self):         #http://localhost:63342/live_tools/svgaPage.html?_ijt=kt3p2cblbp8000nrtnfevsilmb&_ij_reload=RELOAD_ON_SAVE【 This link goes directly into QUrl If so, it will take effect , But it's actually a dynamic address , I can't just write it in like this 】        self.videoEngine.load(QUrl(r"./fansCrad/fans.svga"))          self.horizontalLayout.addWidget(self.videoEngine)   # Put code components into layout Layers         self.videoEngine.show()     # This seems to be OK 
Operation results and error reporting contents

layout The layer changes from transparent to white , The description should be in the past ; But the web content doesn't show at all ; No error content

My solution ideas and tried methods

Because directly speaking, the browser address is copied to url It can be opened , So basically, it can be said that there is no problem with the code ; It should be on this dynamic address .

What I want to achieve

I learned that one way seems to be called reverse compilation ? Does this mean to js The address of content generation is reversed to form a code state that can be used for QURL? I don't understand much .

The solutions I can think of at present are 2 individual ;
1、 Use the server , So you have the address ( But it's really unnecessary ; Just a small program ; And this is not the root of the problem ; There is still no local implementation )
2、 stay main Write directly in the code js?? I don't know if this can be achieved ; After reading a lot of fragmented code, it is incomplete ; So it's hard to understand .

If a friend can help , I hope it can be as complete and popular as possible ( Manual than heart ); by the way , I use it python3 Page is qt-designer The design of the

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2022/112/202204222007297533.html

Random recommended