I’ve been having problems with UltimateListCtrl and wanted to try making a widget that displays a list using HTML and the WebView widget… since I know HTML supports the kind of table coloring and manipulation I want.
The problem I’m having is that I can’t modify the HTML in the WebView widget until it has loaded the HTML page… but WebView.LoadURL returns immediately and later posts the EVT_WEBVIEW_LOADED event. So in my widget subclass, in the init function, I want to wait to return the new htmlList object from the constructor until the EVT_WEBVIEW_LOADED callback is complete.
I’ve tried using threading.Lock(), and also passed the wx.App into the frame, panel, and widget, so I could call app.Dispatch while I couldn’t get a lock… but that didn’t work. I tried calling LoadURL from a thread so I could block the main loop in a busy while loop, and subclasses wx.EvtHandler so I could Bind the event, thinking that calling LoadURL from a thread was causing the event to get lost somewhere. That didn’t work either.
So is there some way to do what I want? I’m at a loss…
<snip>
Why not load the html page to a string, modify it, then pass that to the webview as the initial page?
···
On 04/06/14 05:50, Nathan McCorkle wrote:
I've been having problems with UltimateListCtrl and wanted to try making a widget that displays a list using HTML and the WebView widget... since I know HTML supports the kind of table coloring and manipulation I want.
The problem I'm having is that I can't modify the HTML in the WebView widget until it has loaded the HTML page... but WebView.LoadURL returns immediately and later posts the EVT_WEBVIEW_LOADED event. So in my widget subclass, in the init function, I want to wait to return the new htmlList object from the constructor until the EVT_WEBVIEW_LOADED callback is complete.
I thought about that, but the WebView API only seems to mention ways to load a URL string… not a content string.
http://wxpython.org/Phoenix/docs/html/html2.WebView.html
I supposed I could figure out how to inject the new content with pure javascript, then use RunScript.
Is there an API call I’m not seeing?
···
On Tuesday, June 3, 2014 10:04:36 PM UTC-7, Gadget Steve wrote:
On 04/06/14 05:50, Nathan McCorkle wrote:
I’ve been having problems with UltimateListCtrl and wanted to try
making a widget that displays a list using HTML and the WebView
widget… since I know HTML supports the kind of table coloring and
manipulation I want.
The problem I’m having is that I can’t modify the HTML in the WebView
widget until it has loaded the HTML page… but WebView.LoadURL
returns immediately and later posts the EVT_WEBVIEW_LOADED event. So
in my widget subclass, in the init function, I want to wait to return
the new htmlList object from the constructor until
the EVT_WEBVIEW_LOADED callback is complete.
Why not load the html page to a string, modify it, then pass that to the
webview as the initial page?
You can either create your modified page as a file or in memory and then use a file system handler like in the examples, e.g.: http://wxpython.org/Phoenix/docs/html/MemoryFSHandler.html#memoryfshandler
···
On 04/06/14 20:33, Nathan McCorkle wrote:
I thought about that, but the WebView API only seems to mention ways to load a URL string... not a content string.
http://wxpython.org/Phoenix/docs/html/html2.WebView.html
I supposed I could figure out how to inject the new content with pure javascript, then use RunScript.
Is there an API call I'm not seeing?
This still wouldn’t really solve the issue… since I want to modify the HTML with javascript, after its been loaded… So the idea is you’d instantiate a new WebList object, then maybe you’d add the columns, then append some rows. The problem is if you instantiate this WebList object in your wx.Frame init/constructor… the EVT_WEBVIEW_LOADED callback doesn’t happen until the wx.Frame constructor returns/finishes. So the calls within that constructor to AddColumnInfo or AppendItem fail.
See the attached code (verified to work with wx 3.0, all 3 files needed)… calling AppendItem right after the WebList constructor fails, even calling AppendItem using wx.CallAfter fails (AppendItem still runs before the EVT_WEBVIEW_LOADED callback)
Another problem is why the overflow isn’t working for the table… it’s as if the WebList panel isn’t getting resized by the frame… I even tried subclassing scrolledpanel but that didn’t work either. (Though I think css overflow is the desired UI experience, though scrolledpanel might be fine)
jquery-1.11.0.js (276 KB)
WebList.html (2.57 KB)
WebList.py (5.15 KB)
···
On Wednesday, June 4, 2014 1:58:23 PM UTC-7, Gadget Steve wrote:
On 04/06/14 20:33, Nathan McCorkle wrote:
I thought about that, but the WebView API only seems to mention ways
to load a URL string… not a content string.
http://wxpython.org/Phoenix/docs/html/html2.WebView.html
I supposed I could figure out how to inject the new content with pure
javascript, then use RunScript.
Is there an API call I’m not seeing?
You can either create your modified page as a file or in memory and then
use a file system handler like in the examples, e.g.:
http://wxpython.org/Phoenix/docs/html/MemoryFSHandler.html#memoryfshandler
Maybe wx.Yield() is what I want?
···
On Wednesday, June 4, 2014 4:10:48 PM UTC-7, Nathan McCorkle wrote:
This still wouldn’t really solve the issue… since I want to modify the HTML with javascript, after its been loaded… So the idea is you’d instantiate a new WebList object, then maybe you’d add the columns, then append some rows. The problem is if you instantiate this WebList object in your wx.Frame init/constructor… the EVT_WEBVIEW_LOADED callback doesn’t happen until the wx.Frame constructor returns/finishes. So the calls within that constructor to AddColumnInfo or AppendItem fail.
See the attached code (verified to work with wx 3.0, all 3 files needed)… calling AppendItem right after the WebList constructor fails, even calling AppendItem using wx.CallAfter fails (AppendItem still runs before the EVT_WEBVIEW_LOADED callback)
Another problem is why the overflow isn’t working for the table… it’s as if the WebList panel isn’t getting resized by the frame… I even tried subclassing scrolledpanel but that didn’t work either. (Though I think css overflow is the desired UI experience, though scrolledpanel might be fine)
On Wednesday, June 4, 2014 1:58:23 PM UTC-7, Gadget Steve wrote:
On 04/06/14 20:33, Nathan McCorkle wrote:
I thought about that, but the WebView API only seems to mention ways
to load a URL string… not a content string.
http://wxpython.org/Phoenix/docs/html/html2.WebView.html
I supposed I could figure out how to inject the new content with pure
javascript, then use RunScript.
Is there an API call I’m not seeing?
You can either create your modified page as a file or in memory and then
use a file system handler like in the examples, e.g.:
http://wxpython.org/Phoenix/docs/html/MemoryFSHandler.html#memoryfshandler