Hi Alan,

Thank you so much for guiding me towards this. I am new to tkinter hence
not aware of all these features.
I am trying to find some simple examples, of how to use copy/paste/cut. I
do not have a text box, but a GUI similar to a word editor. I was wondering
if you could direct me towards or show me towards some simple examples of
the same, so that it would be easier to understand. I was learning from
youtube videos about this.
It would be a huge help. Thank you so much

Pooja

On Sat, Feb 4, 2017 at 5:32 AM, Alan Gauld via Tutor <tutor@python.org>
wrote:

> On 04/02/17 00:24, Pooja Bhalode wrote:
>
> > I am trying to write a simple Tkinter code in Python in order to
> > demonstrate select/copy/paste/cut functionalities using keyboard keys and
> > menu options.
>
> You are going a fairly long winded way about it.
> Rather than generating events use the Text/Entry
> widget methods directly.
>
> Check the documentation for the following methods:
>
> Text.get(....)   # copy
> Text.selection_get(...) # copy a selection
> Text.delete(...)  # cut
> Text.insert(...)  # paste
>
> To control selections look at the tag methods,
> but that is more complex.
>
> > def show_menu(e):
> > w = e.widget
> > # the_menu.entryconfigure("Select",command=lambda:
> > w.event_generate("<<Select>>"))
> > the_menu.entryconfigure("Cut",command=lambda:
> w.event_generate("<<Cut>>"))
> > the_menu.entryconfigure("Copy",command=lambda:
> w.event_generate("<<Copy>>"))
> > the_menu.entryconfigure("Paste",command=lambda:
>
> These should be in the create function. You don't need
> to configure the command every time you show the menu.
>
> > w.event_generate("<<Paste>>"))
> > the_menu.tk.call("tk_popup", the_menu, e.x_root, e.y_root)
>
> You should only need to call the tk.call() method very,
> very rarely, there is usually a more direct way to do things.
>
> > root = Tkinter.Tk()
> > make_menu(root)
> >
> > e1 = Tkinter.Entry(); e1.pack()
> > e2 = Tkinter.Entry(); e2.pack()
>
> Shouldn't these Entries have a parent?
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> http://www.amazon.com/author/alan_gauld
> Follow my photo-blog on Flickr at:
> http://www.flickr.com/photos/alangauldphotos
>
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to