Results 1 to 3 of 3

Thread: Python, pygtk, clipboard, rich text?

  1. #1
    Join Date
    Mar 2005
    Location
    Portland, Oregon
    Beans
    433
    Distro
    Ubuntu 7.04 Feisty Fawn

    Python, pygtk, clipboard, rich text?

    Does anyone have any experience working with rich text in the pygtk clipboard dealey? What I want to do, to copy some text, formatting included, onto the clipboard, should be totally straightforward, but, of course, it isn't (plain text is, but that doesn't really help me).

  2. #2
    Join Date
    Mar 2005
    Location
    Portland, Oregon
    Beans
    433
    Distro
    Ubuntu 7.04 Feisty Fawn

    Re: Python, pygtk, clipboard, rich text?

    Okay, I've got a roundabout method going: copying all my text into a gtk.TextBuffer and then using TextBuffer's clipboard-handling facilities (which is supposed to include rich text, isn't it?) to copy to the clipboard, like so:

    Code:
    citation_buffer = gtk.TextBuffer()
    ...
    clipboard = gtk.clipboard_get("CLIPBOARD")
    citation_buffer.select_range(citation_buffer.get_start_iter(), citation_buffer.get_end_iter())
    citation_buffer.copy_clipboard(clipboard)
    Only problem is, all it will paste is plain text. So, next question: Am I maybe going about this all wrong? What I'd like to do is construct a text string that includes formatting for pasting into an openoffice, abiword, etc. document. And if I'm not going about it all wrong, why isn't my app actually including the formatting information?
    Last edited by sethmahoney; December 24th, 2006 at 04:24 AM.

  3. #3
    Join Date
    Mar 2005
    Location
    Portland, Oregon
    Beans
    433
    Distro
    Ubuntu 7.04 Feisty Fawn

    Re: Python, pygtk, clipboard, rich text?

    Update number two (in case anyone's counting): attaching the text buffer to a gtk.TextView shows everything correctly (including formatting), but I still can't paste the text as anything but plain text. Even more bizarre, if I copy and paste directly from the TextView, it *still* pastes as plain text...

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •