Hacker News new | ask | show | jobs
by mathiasgredal 482 days ago
Not exactly related to Ruby on Rails, but why doesn’t there exist a way to run a Python TKinter app in the browser using WASM?

I have a medium sized dependency-free TKinter program written in Python, and AFAIK there is no way to run it in the browser.

1 comments

Because Tk draws using native OS APIs. So you’d need to run the whole OS in the browser.

Or you could implement a new backend for Tk to draw using some web APIs

Or he could use replit which did go to the trouble of implementing a web backend for the tk wm.

There's also a gtk backend for tk (gtkttk), as convoluted as that sounds, so presumably you could use gtk web implementations (broadway) behind that...

In any case, Tk doesn't require an OS to do window drawing, it's entirely up to how things are hooked up.

It’s been awhile, but if you have a browser old enough, here the browser plug-in for TCL/TK: https://www.tcl-lang.org/software/plugin/
That doesn't render a web interface, it just bundles the platform specific executable so you can run scripts embedded in the web browser. Kinda like a hole in the web page into which an exe is shoved.

Also, no browser runs that stuff anymore, and it wouldn'tve been safe to run even when they did.