Python tkinter online
Run tkinter programs in your browser and use their windows: click the buttons, type in the boxes, draw on the canvas.
What works
Widgets
Label, Button, Entry, Text, Checkbutton, Radiobutton, Listbox, Scale, Spinbox, Canvas, Frame, LabelFrame, Message, OptionMenu, and ttk Combobox, Notebook, Progressbar and Treeview.
Layouts
pack with side, fill and expand, grid with sticky, spans and row and column weights, and place with absolute or relative positions.
Variables and events
StringVar, IntVar, DoubleVar and BooleanVar with trace_add, command callbacks, bind for keys and the mouse, and after() for timers and animation.
Dialogs and menus
messagebox (showinfo, askyesno and the rest), simpledialog.askstring and askinteger, and a menu bar with cascades, check and radio items.
How it runs
Your program runs as written. When it reaches mainloop(), the page draws every window it built, and from then on each click, key or change goes back to your callbacks, which update the window. Timers set with after() keep firing, so games and clocks move.
A question asked inside a button's command, such as messagebox.askyesno or simpledialog.askstring, opens as a dialog under the window and waits for your answer. Anything your program prints appears below it, and an error in a callback is shown there without stopping the window.
The same works in the online editor: run a tkinter program there and its window opens in the output panel.
Frequently asked questions
- How does tkinter run in a browser?
- Python runs in your browser, and tkinter calls build the window on the page instead of on the desktop. Your code stays the same: tk.Tk(), widgets, pack or grid, then mainloop().
- Why do other online compilers say "no display" for tkinter?
- Most run Python on a server, which has no screen to open a window on, so tkinter fails with TclError: no display name. Here the window is drawn by the page itself.
- What does not work yet?
- Images (PhotoImage), colours on parts of a Text, widgets placed on a Canvas with create_window, pop-up menus and choosing files. The page says so under the window when a program uses one of them.
- Why does a loop with update() not animate?
- The window appears when the program has finished running, so a while loop that calls update() shows only its last frame. Move each step into a function and call it with root.after(delay, step), the usual tkinter way to animate.
- How do I share a tkinter app I made?
- Press Share link under the window. The link opens your app on a page of its own, window first, with the code a click away and a button to edit a copy. Send to gallery adds it to the tkinter gallery once it has been looked at.
- Can I download my program and run it on my computer?
- Yes. Download .py saves the file, and it runs unchanged with Python from python.org, which includes tkinter (on Linux, install the python3-tk package too). Save picture keeps a PNG of the window for homework or a practical file.
- Can I turn my tkinter program into an .exe?
- Not in the browser, but PyInstaller does it on your own computer with one command. The guide to turning a tkinter app into an .exe has the steps for Windows, macOS and Linux.
- Does it work on a phone or a Chromebook?
- Yes, in any modern browser. Nothing is installed, and the window takes taps and the on-screen keyboard like a desktop window takes clicks and typing.
More: Tkinter app gallery · tkinter app to .exe · Python turtle online · Pygame online · Python programs · Online Python compiler