[Python] Tkinter Window is empty on MacOS

Discussão em 'Python' iniciado por Stack, Outubro 3, 2024.

  1. Stack

    Stack Membro Participativo

    The script is intended to create a window with a navy background and 200 yellow stars, but the window remains empty, and even the background color does not change. But on my friends laptop (he has Windows 11) this code works

    import tkinter
    import random

    n = 200
    width = 800
    height = 600

    root = tkinter.Tk()
    root.title("Hviezdne nebo")

    canvas = tkinter.Canvas(root, width=width, height=height, bg='navy')
    canvas.pack()

    for _ in range(n):
    x = random.randint(0, width)
    y = random.randint(0, height)
    font_size = random.randint(10, 20)
    canvas.create_text(x, y, text='*', fill='yellow', font=('Helvetica', font_size))

    root.mainloop()


    I've tried to reinstall both Python and tkinter - didnt help. Tried this on Windows 11 - it did help

    Continue reading...

Compartilhe esta Página