spaceningui/subfiles/helpers.py

78 lines
1.6 KiB
Python

from CTkMessagebox import CTkMessagebox
import threading
from .savetools import loadFile
try:
from os import startfile
except:
from os import system
from sys import platform
def check():
print("Save Good")
def removeChildren(frame):
for element in frame.winfo_children():
element.destroy()
def bgThread(func, args):
th = threading.Thread(target=func, args=args)
th.daemon = True
th.start()
def openLocation(self, location):
if platform == "linux":
system('xdg-open "%s"' % location)
elif platform == "windows":
startfile(foldername)
def messageBox(self, title, message, type): #type will be implemented at a later point when required
CTkMessagebox(title=title, message=message)
def getLogMax(self, save):
return loadFile(self, save)['maxlogsize'] #not entirely sure why I made this a seperate function but eh
def isNumber(data):
if data == '':
return True
try:
rv = int(data)
except ValueError:
return False
return True
#Old Helper options, left here for future reference. Shitty code, but it works, and it may be useful in the future
# def getlogmax():
# file = 'sngconfig.json'
# if Path(file).is_file():
# with open(file) as f:
# d = json.load(f)
#
# else:
# return False
# def check4sn(configfile):
# file = helpers.getsnpath(configfile) + "package.json"
# if Path(file).is_file():
# with open(file) as f:
# d = json.load(f)
# if (d["name"] == "wf-emulator"):
# return True
# else:
# return False#