Re: [Tkinter-discuss] Cursor coordinates

2009-12-05 Thread Vasilis Vlachoudis
Hi Michael, using your suggestions I've made the routine that works with multilines, and no binary search this time :) Vasilis # - from Tkinter import * import tkFont import string def click(event): global canvas, font, txt canvas.focus_set() canvas.focus(txt

Re: [Tkinter-discuss] Cursor coordinates

2009-12-04 Thread Michael O'Donnell
Ok, The following code demonstrates: a) finding the char index of the insertion cursor in a text item in a Canvas b) translating that char position into pixel position c) drawing a box around the insertion cursor. Did I miss something? from Tkinter import * from tkFont import Font root=Tk()

Re: [Tkinter-discuss] Cursor coordinates

2009-12-04 Thread Michael Lange
On Fri, 4 Dec 2009 19:49:02 + Cameron Laird wrote: > On Fri, Dec 04, 2009 at 08:39:23PM +0100, Michael Lange wrote: > . > . > . > > I think Vasilis meant how to find the coords of the text's insertion > > cursor, not the mouse

Re: [Tkinter-discuss] Cursor coordinates

2009-12-04 Thread Vasilis Vlachoudis
position in the canvas. Cheers Vasilis -Original Message- From: [email protected] on behalf of Michael O'Donnell Sent: Fri 4/12/2009 19:31 To: Vasilis Vlachoudis Cc: [email protected] Subject: Re: [Tkinter-discuss] Cursor coordinates Hi Vasilis, A general m

Re: [Tkinter-discuss] Cursor coordinates

2009-12-04 Thread Michael Lange
Hi, On Fri, 4 Dec 2009 19:31:07 +0100 "Michael O'Donnell" wrote: > Hi Vasilis, > > A general method on all widgets; w.winfo_pointerxy() > >Returns a tuple (x, y) containing the coordinates of the mouse > pointer relative to w's root window. >If the mouse pointer isn't on the same scr

Re: [Tkinter-discuss] Cursor coordinates

2009-12-04 Thread Michael O'Donnell
Hi Vasilis, A general method on all widgets; w.winfo_pointerxy() Returns a tuple (x, y) containing the coordinates of the mouse pointer relative to w's root window. If the mouse pointer isn't on the same screen, returns (-1, -1). Use this method on you canvas. If you canvas is scrolled,

[Tkinter-discuss] Cursor coordinates

2009-12-04 Thread Vasilis Vlachoudis
Hi all, I have a canvas with some editable text (with create_text) in it. How can I get the cursor coordinates x,y from the canvas? The index() function returns only the character index, is there a way to convert the position of a character into x,y coordinates or bbox? Vasilis __