Ich beschäftige mich gerade mit Tkinter in Python 3.
Aktuell würde ich gerne weiße Punkte auf einen schwarzen Bildschirm im Vollbildmodus zeichnen und deren Position mithilfe einer Schleife dauernd abändern.
Mein Code sieht wie folgt aus:
Code: Alles auswählen
from tkinter import *
def paint(x, y):
x1, y1 = (x - 5), (y - 5)
x2, y2 = (x + 5), (y + 5)
root.create_oval(x1, y1, x2, y2, fill="#ffffff")
if __name__ == "__main__":
root = Tk()
root.attributes('-fullscreen', True)
root.geometry("%dx%d+0+0" % (root.winfo_screenwidth(), root.winfo_screenheight()))
root.focus_set()
root.configure(background='black')
root.bind("<Escape>", lambda e: root.quit())
paint(500,500) #Test
root.mainloop()
Leider kommt es beim Aufruf der Funktion paint() zu folgendem Fehler:
Code: Alles auswählen
Traceback (most recent call last):
File "/home/ata/source/Test/main.py", line 19, in <module>
paint(500,500) #Test
File "/home/ata/source/Test/main.py", line 8, in paint
root.create_oval(x1, y1, x2, y2, fill="#ffffff")
File "/usr/lib/python3.6/tkinter/__init__.py", line 2098, in __getattr__
return getattr(self.tk, attr)
AttributeError: '_tkinter.tkapp' object has no attribute 'create_oval'
Gruß
Atalanttore