I am getting ready to work on a small project. I have chose Python and TKInter for GUI management. I am not that familiar with GUI coding in Python yet and I have been reading where TKInter is notorious looking. So, I decided to perform a little experiment and see how close I could get a GUI to looking presentable enough to use on a Mac. Below is my results. I don't think it looks bad at all.
Now, based on the theory of cross-platform, I should be able to move all this code and it work and look presentable on Windows and Linux as well. That is the subject for another post.
Here is the Python 3 code used to create the GUI:
Friday, September 15, 2017
Wednesday, June 14, 2017
# This class handles sprite sheets # This was taken from www.scriptefun.com/transcript-2-using # sprite-sheets-and-drawing-the-background. # I've added some code to fail if the file wasn't found.. # Note: When calling images_at the rect is the format: # (x, y, x + offset, y + offset) # Modifed by Noble Bell for Python 3 import pygame class spritesheet(object): def __init__(self, filename): self.sheet = pygame.image.load(filename).convert() # Load a specific image from a specific rectangle def image_at(self, rectangle, colorkey = None): "Loads image from x,y,x+offset,y+offset" rect = pygame.Rect(rectangle) image = pygame.Surface(rect.size).convert() image.blit(self.sheet, (0, 0), rect) if colorkey is not None: if colorkey is -1: colorkey = image.get_at((0,0)) image.set_colorkey(colorkey, pygame.RLEACCEL) return image # Load a whole bunch of images and return them as a list def images_at(self, rects, colorkey = None): "Loads multiple images, supply a list of coordinates" return [self.image_at(rect, colorkey) for rect in rects] # Load a whole strip of images def load_strip(self, rect, image_count, colorkey = None): "Loads a strip of images and returns them as a list" tups = [(rect+rect*x, rect, rect, rect) for x in range(image_count)] return self.images_at(tups, colorkey)