Wouldn’t it be nice if we could use tkinter on the browser like we do on the pc applications? Well we actually can. We can make it with Repl.it. I asked some time ago to the staff of repl.it if they could implement tkinter in their ‘site’ and they said that they would put that as a new feature maybe in the future. They did it, so now we have the chance to use tkinter in the browser, on a web page, in the posts where we talk about python code. Isn’t this cool? I think so. We can embed the code made in repl.it in our pages and enjoy the graphic user interface made with Python in a web page, not only python, but tkinter. I think we have to learn how to do it, because of the many thing we could implement in a browser that everybody have on their devices. This is the example I made, followed by a video where I show you how easy it is to do it.
The code that I run in Repl.it with tkinter to use it in the browser
import tkinter as tk def pprint(): lab["text"] = "You clicked" # ===== GUI ==== # root = tk.Tk() lab = tk.Label(root, text="Hello World!", font="Arial 36") lab.grid(row=0, column=1) button = tk.Button(root, text="Click", font="Arial 36") button.grid(row=0, column=0) button["command"] = pprint root.mainloop()
This is how it appears on the computer, not in repl.it
This is the embed code in repl with tkinter
Here it is my code with repl.it
Subscribe to the newsletter for updates
Tkinter templates
My youtube channel
Twitter: @pythonprogrammi - python_pygame