def drawIcons(self): if isinstance(self.currentGesture, str): #print('Current Gesture is a string') return collapsed_possibilities = node.get_child_collapsed_possibilities(self.currentGesture) #print('collapsed_possibilities: ' + str(collapsed_possibilities)) for key, child in collapsed_possibilities.iteritems(): iconLocation = self.nodeInDirection(self.currentNode, key) cachedIconList = [] if isinstance(child, str): cachedIconList.append(self.cachedIcons[child]) else: for cachedIconName in child: cachedIconList.append(self.cachedIcons[cachedIconName]) if len(cachedIconList) == 0: return joined = icons.joinImages(cachedIconList, 64, 64) #print('Drawing an icon at ' + str(iconLocation)) self.screen.blit(joined, self.dotDict[iconLocation])
def cacheIcons(self, rules): print("Caching icons") collapsed_possibilities = node.get_child_collapsed_possibilities(rules) for key, child in collapsed_possibilities.iteritems(): print('Child is ' + str(child)) if isinstance(child, basestring): iconHash = str(hash(child))[:8] keepcharacters = (' ','.','_') child = "".join(c for c in child if c.isalnum() or c in keepcharacters).rstrip() icons.loadFile(child, iconHash) #icons.loadFile("C:\\Program Files (x86)\\Audacity\\audacity.exe", iconHash) self.cachedIcons[child] = icons.imageFromFile(iconHash, 32, 32) return for iconName in child: iconHash = str(hash(iconName))[:8] keepcharacters = (' ','.','_') child = "".join(c for c in iconName if c.isalnum() or c in keepcharacters).rstrip() icons.loadFile(iconName, iconHash) #icons.loadFile("C:\\Program Files (x86)\\Steam\\Steam.exe", iconHash) #icons.loadFile("C:\\Program Files (x86)\\Audacity\\audacity.exe", iconHash) self.cachedIcons[iconName] = icons.imageFromFile(iconHash, 64, 64)