Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get the habdle of the object I created in Gtk's Drawing area.

Status
Not open for further replies.

songu

Programmer
Dec 7, 2004
4
CA
Hi, I am trying to create a GUI, where user can add stuff to a system by drawing it in the canvas, then later on user play around with new object. ie, move, delete, assign properties, etc. But I could not find how to get the handle of the object so that I can refer to it later.

Please help and thanks in advance.
 
When you instantiate your new canvas a pointer to it should be returned.
 
Thanks for the reply, but my question is how to get the handles of objects created in the canvas, not the canvas itself.
 
The only thing I can think of (if it's not in the documentation) would be to dir() the canvas object and see it it has methods to get them.
 
Hi,
Yesterday I posted one question about how to get the coordenates of one dot in a dot graph. I resolved the problem using the command "bind" and ericbrunson told me that there was a similar thread.
I don't know if you want to do something similar, but take a look to this command, maybe it will resolve your problem.

Example

define a function ("callback")

def callback(event):
print 'coordenates:',event.x,event.y

join you canvas to the function defined before

display=Canvas(...........)
display.bind("<Double-Button-1",callback)

when you click twice in the Canvas place, the coordenates will be printed.

I don't know if that is what you wanted.
I hope it helps
 
Hi, Guys

Thanks again for the posts. My problem is different than btcpar's.

I find in Tkinter, when I create a object in the canvas, it will return a handle, say "item". Then later, I can just use canvas.move(item, options) to move it to a new location, and use canvas.delete(item) to delete. How can I do similar things in PyGTK? Or maybe without using drawing area, can I use some other widgets?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top