def __init__(self, master): # Global variables global varlist global numvars # Transparent window self.root = master # Set the window size and make slightly transparent w = self.root.winfo_screenwidth() h = self.root.winfo_screenheight() * 0.8 x = WIN10PADDING y = 0 self.root.geometry('%dx%d+%d+%d' % (w, h, x, y)) self.root.attributes('-alpha', 0.2) # Load the constant variables from file c.updatePositionVariables('config.txt') # Load the constants into a local varlist for some reason try: con_file = open('config.txt', "r") except: raise Exception("Couldn't open constants text file") con_reader = csv.reader(con_file) varlist = [] for row in con_reader: if '#' not in row[0]: if row[0] in ('PLAYERPOSLIST', 'PLAYERACTIONPOSLIST'): l = row[1:] o = [[l[i],l[i+1],l[i+2],l[i+3]] for i in range(0,len(l),4)] for i, each in enumerate(o): if i != 0: varlist.append([row[0]+' '+str(i), [float(x) for x in each]]) else: varlist.append([row[0], [float(x) for x in row[1:]]]) numvars = len(varlist) con_file.close() self.canvas = tkinter.Canvas(self.root, bg='red')
def setUp(self): script_dir = os.path.dirname(__file__) dir = os.path.join(script_dir, "files//tests_constants.txt") constants.updatePositionVariables(dir)