Giter Club home page Giter Club logo

Comments (5)

Andereoo avatar Andereoo commented on August 23, 2024 1

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.

Viswas-Programs avatar Viswas-Programs commented on August 23, 2024

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.

nickzoic avatar nickzoic commented on August 23, 2024

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.

Andereoo avatar Andereoo commented on August 23, 2024

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.

nickzoic avatar nickzoic commented on August 23, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.