mburton2

Button Desk change

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