Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I open a website in a Tkinter window?

Tags:

python

tkinter

I am trying to build a simple web browser with Tkinter. I would like to know how I can open a website in Tkinter/Python.

like image 495
Bro Michael Avatar asked Dec 19 '22 06:12

Bro Michael


1 Answers

You cannot easily do what you want. Tkinter has no way to render html. You would have to parse the HTML and CSS and Javascript yourself, and translate the information for display on a canvas or text widget.

If all you want to handle is paragraphs, bold, italic, and headings, it might not be too hard. To render most real-world html with css and javascript would likely take you thousands of hours of work to get right.

At one point there was an effort to create a tkinter html widget, but that project hasn't seen any significant activity in years (http://tkhtml.tcl.tk/), and as far as I know was never integrated with Tkinter. It showed a lot of promise, but it also showed that rendering HTML is a very, very difficult task.

like image 187
Bryan Oakley Avatar answered Dec 21 '22 23:12

Bryan Oakley