Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6125747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:17:01+00:00 2026-05-23T16:17:01+00:00

Using python, one can read in an image: from PIL import Image, ImageTk image

  • 0

Using python, one can read in an image:

from PIL import Image, ImageTk
image = Image.open("test.jpg")

Then one can write to klipper in the following way:

import dbus
bus = dbus.SessionBus()
proxy = bus.get_object("org.kde.klipper","/klipper")
iface = dbus.Interface(proxy,"org.kde.klipper.klipper")
iface.setClipboardContents("text")

But when I try to write an image I just opened – it says it can’t accept it:

iface.setClipboardContents(image)
TypeError: Expected a string or unicode object

So my question is: “how to put an image to klipper with python?”

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T16:17:01+00:00Added an answer on May 23, 2026 at 4:17 pm

    Found some solution – not with python but with bash, and it doesn’t work for remote pictures – works only for local ones (because of gwenview). Here is a bash script:

    #!/bin/bash
    cd /home/boris/Downloads/
    name=`ls -t1 | head -1`
    gwenview $name &
    sleep 3
    id=`ps -e | grep gwenview | awk '{print $1}'`
    qdbus org.kde.gwenview-$id /gwenview/MainWindow_1/actions/edit_copy trigger
    sleep 3
    kill $id
    

    This could also be done with python of cource, but since I make a system call, not read in a picture – there’s no need to use python.

    To explain it – suppose You downloaded an image to ~/Downloads. Then if you the this script it will finds the freshest file in there, opens it with gwenview, copies it to clipboard (!), then closes gwenview.

    I think to work properly – no other gwen’s could be running. And if You want to use it – it’s wise to bind the script to a hotkey.

    The reason I was looking for such a script – is because I want to switch to keyboard-driven webbrowser (such as Conkeror or Pentadactyl) – and it allows to save image quickly – while I mostly need to paste it to some .odt file).

    This script can further be made a daemon – which will watch the Downloads dir. But now I to write a script which will download image, and put to clipboard automatically – please see my next question.

    The way to find qdbus command you might need – is to open

    qdbusviewer
    

    and find the app you need, then the command you need, and then make call similarly it’s done to, e.g. lock the screen:

    qdbus org.kde.krunner /ScreenSaver Lock
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I read from standard input and write to standard output. System.Diagnostics.Process.StandardInput's MSDN
Using Python (3.1 or 2.6), I'm trying to read data from binary data files
I'm using Python 2.6 and PyGTK 2.22.6 from the all-in-one installer on Windows XP,
Using Python, how does one parse/access files with Linux-specific features, like ~/.mozilla/firefox/*.default ? I've
I'm building a centralized desktop application using Python/wxPython. One of the requirements is User
I'm currently learning Python using Zelle's Introductory text, and I'm trying to recreate one
Is there a benefit to using one over the other? In Python 2, they
I am extending Python with some C++ code. One of the functions I'm using
Using Python2.4 I want to capture output from a mysql command. One caveat is
Using python 2.4 and the built-in ZipFile library, I cannot read very large zip

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.