simulating keyboard events

Martin Franklin mfranklin1 at gatwick.westerngeco.slb.com
Mon Mar 31 09:21:00 EST 2003


On Monday 31 March 2003 14:59, Martin Franklin wrote:
> On Monday 31 March 2003 14:21, Michael Hudson wrote:
> > student00 at angelfire.com (student) writes:
> > > is there an easy way to simulate a keyboard event in python..
> >
> > I doubt it, but I don't actually know...
>
> I don;t really know how to do this either but read on.....
>
> > > i need to send a 'Delete' key event to a text widget (at the current
> > > cursor position/selection)
>
> If this is a Tkinter Text widget and all you want to do is delete the last
> inserted character then this should work:-
>
> text.delete("insert - 1 char", "insert")
>

Whoops I should have read the OP more carefully....  you may also need this 
call to delete the selected text

text.delete("sel.first", "sel.last")


Cheers
Martin






More information about the Python-list mailing list