Advertisement
mburton2

change desktop

Oct 27th, 2017
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.30 KB | None | 0 0
  1. import wx
  2. import os
  3. import shutil
  4. import ctypes
  5.  
  6.  
  7. class Window(wx.Frame):
  8.     def __init__(self, parent, id):
  9.         self.dPics = "C:\Desktop background"
  10.         self.list = []
  11.         self.SPI_SETDESKWALLPAPER = 20
  12.         no_caption = wx.DEFAULT_FRAME_STYLE | wx.STAY_ON_TOP
  13.         wx.Frame.__init__(
  14.             self, parent, id, title="no_caption",
  15.             size=(300, 105), style=no_caption)
  16.         self.panel = wx.Panel(self)
  17.         self.cBack = wx.Button(
  18.             self.panel, -1, label="Change",
  19.             pos=(0, 0), size=(100, 70))
  20.         self.cBack.Bind(wx.EVT_BUTTON, self.ChangeDesk, self.cBack)
  21.         self.dPicsFull = os.listdir(self.dPics)
  22.         self.counter = 0
  23.         for self.items in self.dPicsFull:
  24.             self.fullPath = os.path.join(self.dPics, self.items)
  25.             if self.fullPath.endswith(('.jpg', '.png')):
  26.                 self.list.append(self.fullPath)
  27.  
  28.     def ChangeDesk(self, e):
  29.         ctypes.windll.user32.SystemParametersInfoA(
  30.             self.SPI_SETDESKWALLPAPER, 0, self.list[self.counter], 3)
  31.         self.counter += 1
  32.         if self.list[self.counter] == self.list[-1]:
  33.             self.counter = 0
  34.  
  35. if __name__ == '__main__':
  36.     app = wx.App(False)
  37.     frame = Window(parent=None, id=-1)
  38.     frame.Show()
  39.     app.MainLoop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement