tkinter in the browser
A program with a window, buttons and text fields is a big step for a student: the code stops being a list of commands run top to bottom and starts reacting to events. In Python the simplest way there is tkinter from the standard library. In BitWizards everything runs in a browser tab: you write code, click Run and the app window appears next to the editor, ready to be clicked, typed into and closed with the X.
Course: Python desktop apps, tkinter step by step - first lesson (lessons are in Polish)
Window and widgets
Regular import tkinter as tk code works: a tk.Tk() window with a title and size, the Label, Button, Entry, Text, Checkbutton, Radiobutton, Scale, Spinbox, Listbox, Frame, LabelFrame and Toplevel widgets, the bg, fg, font, width and state options, and StringVar, IntVar, DoubleVar, BooleanVar. Layout is computed like Tk: pack (sides, fill, expand), grid (rows, columns, sticky, columnspan, weights) and place. messagebox and simpledialog dialogs show up above the app window, and root.after() works as a timer. There is also a Canvas you can draw on with the mouse, a menu bar and context menus, ttk widgets (Combobox, Treeview, Notebook, Progressbar) and filedialog file pickers.
print goes to the console under the window, and an error in an event handler is printed just like in regular Python (“Exception in Tkinter callback”) without closing the app.
Step-by-step course
Python desktop apps: tkinter step by step (14 topics, 110 examples and tasks) goes from the first window to games and apps with files: the first window and labels, buttons and events, text fields and numbers, pack and grid layout with frames, check boxes, sliders and spinboxes, message boxes and questions, Listbox lists, and projects (a unit converter, a sign-up form with validation, a grade book, a stopwatch with after, an app written as a class), then drawing and animation on a Canvas (a coin-catching game), menus and Toplevel windows, ttk widgets, files with filedialog, and larger projects (a calculator, tic-tac-toe, a quiz from a file). Code uses English identifiers; the texts users see are in Polish.
Checked like a user
A tkinter task has a two-part rule:
- window widgets - type, variable name (also
app.labelin an app written as a class), text, options (e.g.bg="green",show="*"), layout position (grid(row=0, column=1),pack(side="left")) and the frame it sits in, - scenarios - steps on the running program: type, click, press a key, tick, move a slider, pick from a list, answer a message box, wait (the
afterclock is virtual, so a minute takes a moment), close the window, then expect a label, a list size, a selection, a widget option or a message.
Checking runs after every Run and does not disturb the student’s running app. A failed condition is explained: which scenario, what was expected and what the window showed.
For teachers
- Your own tasks with a
tkrule: starter code and a JSON rule with an example to adapt, checked by the same engine as the course. - Student work history and live view during the lesson, as in other tasks.
- Timed mock exams with tab-switch signals.
Limitations
To be honest about what is missing: PhotoImage pictures from files, ttk.Style themes (ttk widgets look like Windows 10), dragging windows and resizing them with the mouse (geometry sets the size), the system clipboard and libraries outside the standard library (e.g. customtkinter, PIL). The window looks like Windows, but is not pixel-identical.