Reputation: 4940
We have been having a problem with loading files using wxPython the use case is that we have these files/snips on a folder on the computer. The snips are a small section of an original html file - many times the snips are an extracted table with html and body tags wrapped around the table
<html><body><table>
~tr and td tags with stuff in them
</table></body><<html>
The user navigates to the folder using the SmartBrowser (our application) which then makes a list of the htm and txt files in the folder and displays the first one. We have controls to move through the list (next and previous)
This system has worked well with few glitches for a couple of years. All of a sudden the SmartBrowser (the name of the application that allows viewing of the snips) started crashing when certain snips were loading. I finally isolated the problem to determine that the crash was happening
If I simply change the width attribute to some nonsense word (say banana) then everything displays normally and the program does not crash but if the width attribute is present then the following error message shows up in the command console running to try to debug
hello wolr
Traceback (most recent call last):
File "gui\smart_browser.pyo", line 286, in onOpen
File "gui\smart_browser.pyo", line 219, in browseTo
File "gui\smart_browser.pyo", line 170, in update
File "gui\smart_browser.pyo", line 231, in loadUrl
File "wx\html.pyo", line 1008, in LoadPage
wx._core.PyAssertionError: C++ assertion "(size_t)(n) <= length()" failed at ..\
..\include\wx/string.h(433) in wxStringBase::at(): invalid index in wxString
Let me emphasize again - this behavior just recently showed up - we had moved to WxPython 2.9 but rolled back to 2.8 to see if that was the cause but we did not see any behavior difference.
So I found the function in the error message in wx\html.py
def LoadPage(*args, **kwargs):
"""LoadPage(self, String location) -->bool"""
return _html.HTMLWindow_LoadPage(*args, **kwargs)
However I see that the program is importing from _html and forgive me here but now it looks like I am getting in over my head as _html
is a pyd
file - which appears to be a type of dll
??
I am not sure what to do next as I can't figure out why the WIDTH attribute causes the error I poked around on the WxWidgets
site and I can't seem to find any evidence that this combination would be a problem. I am not sure what I should look at next.
Specifically I am looking for suggestions as to what I need to read to sort out this problem and maybe an indication that we should handle this outside Wx
or get into Wx
which for someone with my skills seems scary.
Well I will add more based on Mike Driscoll's answer the code did have this
try:
from wx.lib.iewin import IEHtmlWindow as HtmlWindow
LOAD_URL_FUNC_NAME = 'LoadUrl'
GET_URL_PROPERTY_NAME = "locationurl"
except:
from wx.html import HtmlWindow
LOAD_URL_FUNC_NAME = 'LoadPage'
GET_URL_PROPERTY_NAME = "OpenedPage"
And he was exactly correct I commented out the conditional import and after some more study determined that I needed to
from wx.lib.iewin_old import IEHtmlWindow as HtmlWindow
Notice the iewin_old I assumed we were usingIEHtmlWindow but we were not because of an error with the import that was resolved when I went to iewin_old
Upvotes: 1
Views: 322
Reputation: 33101
I can't tell for certain from the little bit of code you're showing, but I am guessing you are using HTMLWindow. The HTMLWindow widget only works with a limited set of HTML tags, so I'm guessing it's not happy with that attribute. I suspect that you basically have two options:
You could also ask on the wxPython Google group / users list for other suggestions.
Upvotes: 1