On 15/11/12 02:32, Matheus Soares da Silva wrote:

Hello, I would like to be able to get information from a Tkinter canvas
object. (color, width, tags, root points, etc),

  I wrote the following function that, with a canvas bind, returns me
the widget that has been clicked on, the widget is returned as a tuple
by the find_overlapping method.

# detecting click
def Hasclicked(e):
     global obj
     global lastClick
     lastClick = [e.x, e.y]
     obj = e.widget.find_overlapping(e.x, e.y, e.x, e.y)

   So, there's any method I can use on 'obj' to get the attributes?

Do you want to get the attributes of the object within the canvas or of the canvas itself?
I'm not quite clear from your description?

In either case you can access an attribute of an object using standard Tkinter attribute access mechanism: obj['attributeName']

>>> import Tkinter as tk
>>> top = Tk()
>>> top = tk.Tk()
>>> l = tk.Label(top,text='hello')
>>> l.pack()
>>> l['text']
'hello'
>>>

HTH

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to