Python control of desktop properties

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mediocre Person

    #1

    Python control of desktop properties

    Hello, all.

    I'm teaching Python for the first time to some high school students, and
    it's going well--Tomorrow's lesson: I'm going to show them how to use a
    list comprehension to simplify a task.

    One of my students is interested in using Python to control his
    (Windows) desktop, and wants to write a program to change the desktop
    background or wallpaper. I told him I'd look into this, but I've had to
    admit defeat.

    Can someone point me in the right direction, possibly post the simplest
    Python program that can accomplish this. I understand this won't be
    portable. At school, we use Win98SE; the student in question is using
    XPHome at home, and I typically use Gentoo Linux/KDE 3.3. If there were
    a single solution that would address all three environments, I'd be...
    well, shocked.

    Merci beaucoup,

    Nick.
  • Mike C. Fletcher

    #2
    Re: Python control of desktop properties

    You want to call the function:
    user32.SystemPa rametersInfo(
    SPI_SETDESKWALL PAPER,
    0,
    imageLocation,
    |SPIF_UPDATEINI FILE | SPIF_SENDWININI CHANGE
    )

    You can likely do that fairly readily with ctypes. Sorry, don't have
    time to do more than point you at it tonight.

    Good luck,
    Mike
    |

    _______________ _______________ _______________ ___
    Mike C. Fletcher
    Designer, VR Plumber, Coder



    Comment

    • Simon Brunning

      #3
      Re: Python control of desktop properties

      On Tue, 12 Oct 2004 20:28:45 -0500, Mediocre Person
      <mediocre_perso n@hotmail.com> wrote:[color=blue]
      > One of my students is interested in using Python to control his
      > (Windows) desktop, and wants to write a program to change the desktop
      > background or wallpaper. I told him I'd look into this, but I've had to
      > admit defeat.[/color]

      I've been having a play in that area on and off. This isn't well
      documented, but might get you started...

      <http://www.rafb.net/paste/results/2Wglzu95.html>
      [color=blue]
      > Can someone point me in the right direction, possibly post the simplest
      > Python program that can accomplish this. I understand this won't be
      > portable. At school, we use Win98SE; the student in question is using
      > XPHome at home, and I typically use Gentoo Linux/KDE 3.3. If there were
      > a single solution that would address all three environments, I'd be...
      > well, shocked.[/color]

      Me too. ;-)

      --
      Cheers,
      Simon B,
      simon.brunning@ gmail.com,

      Comment

      • agarbutt@gmail.com

        #4
        Re: Python control of desktop properties

        To do this on windows you need to import ctypes (which you may need to
        download, http://starship.python.net/crew/theller/ctypes/) and win32con
        (which you should have already but if not you can get it from
        https://sourceforge.net/projects/pywin32/). to change th wall paper
        use:

        from ctypes import *
        import win32con

        windll.user32.S ystemParameters InfoA(SPI_SETDE SKWALLPAPER, 0, r'<path to
        your bitmap>', SPIF_SENDWININI CHANGE)

        for further reference on SystemParameter sInfoA goto:
        http://msdn.microsoft.com/library/de...metersinfo.asp

        Hope this helps

        Andy
        Mediocre Person wrote:[color=blue]
        > Hello, all.
        >
        > I'm teaching Python for the first time to some high school students,[/color]
        and[color=blue]
        > it's going well--Tomorrow's lesson: I'm going to show them how to use[/color]
        a[color=blue]
        > list comprehension to simplify a task.
        >
        > One of my students is interested in using Python to control his
        > (Windows) desktop, and wants to write a program to change the desktop[/color]
        [color=blue]
        > background or wallpaper. I told him I'd look into this, but I've had[/color]
        to[color=blue]
        > admit defeat.
        >
        > Can someone point me in the right direction, possibly post the[/color]
        simplest[color=blue]
        > Python program that can accomplish this. I understand this won't be
        > portable. At school, we use Win98SE; the student in question is using[/color]
        [color=blue]
        > XPHome at home, and I typically use Gentoo Linux/KDE 3.3. If there[/color]
        were[color=blue]
        > a single solution that would address all three environments, I'd[/color]
        be...[color=blue]
        > well, shocked.
        >
        > Merci beaucoup,
        >
        > Nick.[/color]

        Comment

        • Mediocre Person

          #5
          Re: Python control of desktop properties

          Mediocre Person wrote:
          [color=blue]
          >
          > One of my students is interested in using Python to control his
          > (Windows) desktop, and wants to write a program to change the desktop
          > background or wallpaper. I told him I'd look into this, but I've had to
          > admit defeat.
          >[/color]

          Thank to all for the replies--got the code working now.

          Nick.

          Comment

          Working...