Comments (5)
Thanks for the suggestion @nickzoic. I added some code that scans tables after they have loaded, which seems be a good workaround for this issue. @lalitdagre, upgrade TkinterWeb, and let me know if the issue still persists!
from tkinterweb.
I think renaming the function will do the trick, because the function names are clashing between myhtmlframe.on_form_submit
and yourfile.on_form_submit
method.
I'm not sure though
from tkinterweb.
This is going to sound ridiculous, but if you remove the <table>
and <tr>
elements from your example code it works as expected. Interestingly if I add a third <tr><form>
etc, the first two work and the third one doesn't!
It seems like when the table is there, TkInterWeb.on_form
is getting called with the wrong widgets, and thus failing to set up the last form correctly? I don't really understand how the parsing/widget replacement logic is working though.
As a workaround, you can have one form wrapped around the whole table, and work out which button is pressed by giving the <input type="submit">
buttons distinct names, eg:
<form>
<table><tr>
<td>Site1<a href="test.html"></a><input type="hidden" name="myhidden1" value="site1"></td>
<td><input type="submit" name="submit1" value="Open in Browser"></td>
</tr><tr>
<td>site2<a href="test1.html"></a><input type="hidden" name="myhidden2" value="site2"></td>
<td><input type="submit" name="submit2" value="Open in Browser"></td>
</tr>
</table></form>
</html>
... then you'll see a ?myhidden1=site1&myhidden2=site2&submit1=Open+in+Browser
for the first button and ?myhidden1=site1&myhidden2=site2&submit2=Open+in+Browser
for the second button ...
from tkinterweb.
Hi! I noticed the same thing earlier. It does seem ridiculous, but it looks like the underlying Tkhtml code is not able to detect items inside tables while loading.
To answer your question @nickzoic, every time a new form is detected, the document is scanned for buttons or inputs, which are added to the form if they have not already been detected. Let's say that there are only two forms. Normally, as each first form is parsed, the items inside are detected and added to a table that matches form elements with their corresponding form. This table is used to figure out which information to include when a form is submitted. With tables, though, no items are detected inside the current form. This means that nothing is added to the table for the first form, and when the second form is loaded, nothing is found inside the second form, but the items that should have been detected in the first form are found and are then added to the second form. Weird.
I've updated the source code to scan each individual form for content rather than the document as a whole. This fixes the weird behaviour with tables getting mixed up, and an input that is not inside a form will no longer be assigned to the first form present, but this also means that now forms inside tables do absolutely nothing. I'm not sure which is better. Let me know what you think.
As this seems to be a strange bug in the underlying html engine, it doesn't look like there is anything I can do on my end. The best I can suggest is to try not to use tables for forms (i.e. try using a <div>
instead).
from tkinterweb.
Isn't that weird! Yeah, I worked out your code for detecting form fields, but haven't looked under the hood of Tkhtml and I'm a little bit afraid to :-)
I'm guessing it builds the table widget tree separately and then adds it to the document widget tree when it finishes laying it out, so the embedded form can't be found until then, or something like that anyway. As you point out, the form is there in the tree when the next form loads. I wonder if it'd work better to wait for the whole document to finish loading before doing the form field scan?
PS: I think setup.py is on PyPI but missing from the github repo?
from tkinterweb.
Related Issues (20)
- Feature Request: Publish Wheel HOT 2
- Selenium support (Making Contact) HOT 4
- Is it possible to get TKHTML3 to render to postscript?
- [Suggestion] split get_node_attribute into 2 methods HOT 1
- PIL not working. HOT 3
- Почему не поддерживает файл png? HOT 5
- Where exactly did you get the TKHTML binaries & how is their source code compiled? HOT 1
- How to compile htmlwidget.MODIFIED.zip? HOT 10
- Support for img alt attribute? HOT 1
- AttributeError: module 'os' has no attribute 'uname' HOT 2
- "RuntimeError: main thread is not in main loop" when trying to load an image that loads elsewhere HOT 2
- Question: Crashes in Tkhtml30.dylib on Mac (Intel) HOT 1
- HtmlFrame doesn't respect height value HOT 7
- Node for found text HOT 10
- Specify font HOT 3
- HtmlFrame widget is trying to interpret the file path as a web URL instead of a local file path when I try to load a folium map. HOT 1
- crash with signal SIGSEGV during loading html into HtmlFrame HOT 3
- AttributeError: 'FreeTypeFont' object has no attribute 'getsize' HOT 2
- Change scroll bar color HOT 2
- [BUG]: Not loading `linear-gradient` CSS. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tkinterweb.