Danke, hat geklappt.Jetzt habe ich allerdings das Problem dass ich die .bind Methode nicht auf ein Frame anwenden kann. Kann mir bitte jemand erklären warum es nicht funktioniert ?
Wenn jemand zeit und lust hat könnte er mir dann erklären wie das mit den Events genau funktioniert.
Hier eine Website von der ich das mit den Events "gelernt" hab:
http://www.pythonware.com/library/tkint ... ndings.htm
Code: Alles auswählen
from tkinter import *
def mouse_left(event):
grid_info = event.widget.grid_info()
x = grid_info["row"]
y = grid_info["column"]
Button(raster, relief="flat", image = icon_0, bd = 0, height=30, width=30).grid(row=x, column=y)
def mouse_right(event):
grid_info = event.widget.grid_info()
x = grid_info["row"]
y = grid_info["column"]
Button(raster, relief="flat", image = icon_1, bd = 0, height=30, width=30).grid(row=x, column=y)
root = Tk()
area_len = 20
icon_0 = PhotoImage(file="icon.gif")
icon_1 = PhotoImage(file="icon1.gif")
icon_2 = PhotoImage(file="icon2.gif")
raster = Frame(root)
Label(raster, width=30, text="Select Item").grid(row=0, column=+area_len)
for x in range(0, area_len):
for y in range(0, area_len):
Button(raster, relief="flat", image = icon_0, bd = 0, height=30, width=30, command=lambda:mouse_right).grid(row=x, column=y)
raster.grid(row=0, column=0)
raster.bind("<Button-3>", mouse_left)
raster.bind("<Button-1>", mouse_right)
mainloop()
Danke im Voraus