Andereoo/TkinterWeb

Feature request: Navigation keys

rodneyboyd opened this issue · 3 comments

It's nice that HTMLFrame adds its own vertical scrollbar, but the navigation keys PageUp, PageDown, Home, and End don't seem to have any effect.

Thanks.

Hi!

Right now these keys are not bound by default. I try to keep bindings to a minimum because they might conflict with the code running TkinterWeb. To bind PageUp and PageDown, you could use:

frame.bind_all("<Prior>", lambda e: frame.html.yview_scroll(-5, "units"))
frame.bind_all("<Next>", lambda e: frame.html.yview_scroll(5, "units"))

Do you think it would be better to provide these bindings by default?

I see your point about the bindings. Maybe if you included them as a useful tip in the documentation that would be enough.

What you suggested worked (I used 25, not 5). Thanks.

This also worked:

html_frame.bind_all("<Prior>", lambda e: html_frame.html.yview_scroll(-1, "pages"))
html_frame.bind_all("<Next>", lambda e: html_frame.html.yview_scroll(1, "pages"))

And this, for the other keys:

html_frame.bind_all("<Home>", lambda e: html_frame.html.yview_moveto(0))
html_frame.bind_all("<End>", lambda e: html_frame.html.yview_moveto(1))

Thanks for the suggestion. I added an example at the top of the Tips & Tricks section of the HtmlFrame docs. I also added a reference below the main example in README.md and in the FAQs. Hopefully that should suffice.