Small projectIntermediate30 XPExercise 4/8

Screensaver

Task

Make a screensaver: the window has a text field (Entry) and a button (Button). The user types a text into the field and after pressing the button the text starts appearing again and again on the canvas - each time at a random place and in a random colour, at regular intervals (for example every second).

The program runs in a tkinter simulation right in your browser - after Run you see the window and can click it. The tests click and check what was drawn on the canvas.

Examples

  • Call

    from tkinter import _mente as okno
    
    okno.check("okno ma textove pole a tlacidlo", len(okno.entries()) >= 1 and len(okno.buttons()) >= 1)
    okno.type("Mente")
    okno.press()
    okno.wait(20000)
    texty = [t for t in okno.created("text") if t.text.strip() == "Mente"]
    okno.check("text sa objavuje opakovane", len(texty) >= 3, f"text sa objavil {len(texty)}-krat")
    okno.check("na roznych miestach", len({(round(t.coords[0]), round(t.coords[1])) for t in texty}) >= 3)
    okno.check("v roznych farbach", len({t.fill for t in texty}) >= 2)
    okno.check("postupne v case", len({t.created for t in texty}) >= 3)

    Expected output

    okno ma textove pole a tlacidlo: OK
    text sa objavuje opakovane: OK
    na roznych miestach: OK
    v roznych farbach: OK
    postupne v case: OK

After you submit, 1 hidden test will also check your solution: a different text.

Python starts the first time you run code.

Ctrl+Enter runs the program. Tab indents. Press Esc, then Tab, to leave the editor.

Input (stdin)

Each line = one call to input().

Output

Hints

Try it yourself first. Each hint reveals a little more - and lowers the reward a little.

Signed out, hints are free - but no XP is awarded either.

Solution

The solution unlocks after the last hint.