Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #105440

Re: Copy To Clipboard Highlighted Text From Text Widget

From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Subject Re: Copy To Clipboard Highlighted Text From Text Widget
Date 2016-03-22 14:46 +1100
Message-ID <mailman.481.1458618385.12893.python-list@python.org> (permalink)
References <s6ednccPwOtSA23LnZ2dnUU7-bOdnZ2d@giganews.com> <mailman.478.1458611235.12893.python-list@python.org> <s_qdnf8l9J8rIG3LnZ2dnUU7-ecAAAAA@giganews.com>

Show all headers | View raw


On Tue, Mar 22, 2016 at 2:36 PM, Wildman via Python-list
<python-list@python.org> wrote:
> Thanks.  I changed the code as you (and MRAB) suggested.
>
> def copy_clipboard(self):
>     try:
>         text2copy = self.text.get(tk.SEL_FIRST, tk.SEL_LAST)
>     except tk.TclError:
>         text2copy = self.text.get()
>     root.clipboard_clear()
>     root.clipboard_append(text2copy)
>
> Works perfectly.  Thanks again.

Looks good!

For future reference, and for others reading, this was a great
question. You posted actual code, with a specific question, and it was
easy to figure out what's going on. Thank you.

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Copy To Clipboard Highlighted Text From Text Widget Wildman <best_lay@yahoo.com> - 2016-03-21 20:24 -0500
  Re: Copy To Clipboard Highlighted Text From Text Widget Chris Angelico <rosuav@gmail.com> - 2016-03-22 12:47 +1100
    Re: Copy To Clipboard Highlighted Text From Text Widget Wildman <best_lay@yahoo.com> - 2016-03-21 22:36 -0500
      Re: Copy To Clipboard Highlighted Text From Text Widget Chris Angelico <rosuav@gmail.com> - 2016-03-22 14:46 +1100
  Re: Copy To Clipboard Highlighted Text From Text Widget MRAB <python@mrabarnett.plus.com> - 2016-03-22 02:01 +0000
    Re: Copy To Clipboard Highlighted Text From Text Widget Wildman <best_lay@yahoo.com> - 2016-03-21 22:31 -0500

csiph-web