Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """ Sims 4 Backup Tool """
- from tkinter import *
- from tkinter import messagebox
- from distutils.dir_util import copy_tree
- import os
- import sys
- import shutil
- import datetime
- #Create and name window
- root = Tk()
- root.title("Sims 4 Backup Tool")
- #Title header
- title = Label(root, text="Sims 4 Backup Tool")
- title.pack()
- pathToSimsFolder = os.path.expanduser("~\\Documents\\Electronic Arts\\The Sims 4\\")
- #Get current date function
- def getDate():
- date = datetime.date.today().strftime("%d-%m-%Y")
- return date
- #Check if folder exists
- def createFolder():
- if os.path.exists(getDate()) == False:
- os.mkdir(getDate())
- #Create folder function
- def createSubFolder(name):
- if os.path.exists(str(getDate())+"/"+name):
- shutil.rmtree(str(getDate())+"/"+name)
- os.mkdir(str(getDate())+"/"+name)
- #Backup Selection function
- def backupSelection():
- """
- This function is called when the 'Backup Selection' button is pressed.
- It decides which boxes are ticked and runs their corrosponding function.
- """
- createFolder()
- if savesSelected.get() == 1:
- backupSaves()
- if modsSelected.get() == 1:
- backupMods()
- if traySelected.get() == 1:
- backupTray()
- if screenshotsSelected.get() == 1:
- backupScreenshots()
- if videosSelected.get() == 1:
- backupVideos()
- if musicSelected.get() == 1:
- backupMusic()
- if savesSelected.get() == 0 and modsSelected.get() == 0 and traySelected.get() == 0 and videosSelected.get() == 0 and screenshotsSelected.get() == 0 and musicSelected.get() == 0:
- messagebox.showerror("Error", "Please select at least one option!")
- #Alert function
- def alert():
- """
- This function is called when a checkbox is ticked.
- It returns a list of the current status of all five checkboxes to the console.
- """
- print("Saves: %s\nMods: %s\nTray: %s\nScreenshots: %s\nVideos: %s\n" % (savesSelected.get(), modsSelected.get(), traySelected.get(), screenshotsSelected.get(), videosSelected.get()))
- #Backup Saves function
- def backupSaves():
- print("Backing up Saves!")
- createSubFolder("saves")
- try:
- copy_tree(pathToSimsFolder+"saves", getDate()+"\\saves")
- except:
- messagebox.showerror("Error", "Unable to copy saves file!")
- #Backup Mods function
- def backupMods():
- print("Backing up Mods!")
- createSubFolder("Mods")
- try:
- copy_tree(pathToSimsFolder+"Mods", getDate()+"\\Mods")
- except:
- messagebox.showerror("Error", "Unable to copy mods file!")
- #Backup Tray function
- def backupTray():
- print("Backing up Tray!")
- createSubFolder("Tray")
- try:
- copy_tree(pathToSimsFolder+"Tray", getDate()+"\\Tray")
- except:
- messagebox.showerror("Error", "Unable to copy tray file!")
- #Backup Screenshots function
- def backupScreenshots():
- print("Backing up Screenshots!")
- createSubFolder("screenshots")
- try:
- copy_tree(pathToSimsFolder+"Screenshots", getDate()+"\\Screenshots")
- except:
- messagebox.showerror("Error", "Unable to copy screenshots file!")
- #Backup Videos function
- def backupVideos():
- print("Backing up Videos!")
- createSubFolder("Recorded Videos")
- try:
- copy_tree(pathToSimsFolder+"Recorded Videos", getDate()+"\\Recorded Videos")
- except:
- messagebox.showerror("Error", "Unable to copy videos file!")
- #Backup Music function
- def backupMusic():
- print("Backing up Custom Music!")
- createSubFolder("Custom Music")
- try:
- copy_tree(pathToSimsFolder+"Custom Music", getDate()+"\\Custom Music")
- except:
- messagebox.showerror("Error", "Unable to copy custom music file!")
- #Tickbox variables
- savesSelected = IntVar()
- modsSelected = IntVar()
- traySelected = IntVar()
- screenshotsSelected = IntVar()
- videosSelected = IntVar()
- musicSelected = IntVar()
- #Frame to contain options
- optionFrame = Frame(root)
- optionFrame.pack()
- #Saves Option
- savesOptionCheck = Checkbutton(optionFrame, text = "Saves", variable = savesSelected, command = alert)
- savesOptionCheck.grid(column=0, row=0)
- #Mods Option
- modsOptionCheck = Checkbutton(optionFrame, text = "Mods", variable = modsSelected, command = alert)
- modsOptionCheck.grid(column=0, row=1)
- #Tray Option
- trayOptionCheck = Checkbutton(optionFrame, text = "Tray", variable = traySelected, command = alert)
- trayOptionCheck.grid(column=0, row=2)
- #Screenshots Option
- screenshotsOptionCheck = Checkbutton(optionFrame, text = "Screenshots", variable = screenshotsSelected, command = alert)
- screenshotsOptionCheck.grid(column=0, row=3)
- #Videos Option
- videosOptionCheck = Checkbutton(optionFrame, text = "Videos", variable = videosSelected, command = alert)
- videosOptionCheck.grid(column=0, row=4)
- #Music Option
- musicOptionCheck = Checkbutton(optionFrame, text = "Custom Music", variable = musicSelected, command = alert)
- musicOptionCheck.grid(column=0, row=5)
- #Backup Button
- backupButton = Button(text="Backup Selection", command=backupSelection)
- backupButton.pack()
- #Run GUI
- root.mainloop()
- """
- I love you Hazel!! xx
- """
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement