def __init__(self, width, height, owner): ScreenGUI.__init__(self, width, height, owner) border = Border(width, height) self.buttons = Enum("BARCODE", "DESCRIPTION", "PRICE", "DONE", "CANCEL") # # # # Fixed position objects # # minx = border.inner_x() + 4 * Widths.BORDER maxx = width - Widths.BORDER miny = border.inner_y() + 4 * Widths.BORDER maxy = height - Widths.BORDER buttonh = 50 buttonw = 100 fullwidth = maxx - minx self.default_text = { self.buttons.BARCODE: "1. Scan an item", self.buttons.DESCRIPTION: "2. Type a description", self.buttons.PRICE: "3. Set a price", } self.objects = { self.buttons.BARCODE: LCARSCappedBar(pygame.Rect(minx, miny, fullwidth, buttonh), CapLocation.CAP_LEFT + CapLocation.CAP_RIGHT, "1. Scan an item", Colours.ENTRY, Colours.BG, True), self.buttons.DESCRIPTION: LCARSCappedBar( pygame.Rect(minx, miny + (2 * buttonh), fullwidth, buttonh), CapLocation.CAP_LEFT + CapLocation.CAP_RIGHT, "2. Type a description", Colours.ERR, Colours.BG, True), self.buttons.PRICE: LCARSCappedBar( pygame.Rect(minx, miny + (4 * buttonh), fullwidth, buttonh), CapLocation.CAP_LEFT + CapLocation.CAP_RIGHT, "3. Set a price", Colours.ERR, Colours.BG, True), self.buttons.DONE: LCARSCappedBar(pygame.Rect(minx, maxy - buttonh, buttonw, buttonh), CapLocation.CAP_LEFT + CapLocation.CAP_RIGHT, "Done", Colours.FG, Colours.BG, True), self.buttons.CANCEL: LCARSCappedBar( pygame.Rect(maxx - buttonw, maxy - buttonh, buttonw, buttonh), CapLocation.CAP_LEFT + CapLocation.CAP_RIGHT, "Cancel", Colours.FG, Colours.BG, True), } # # # # Import standard objects # # self.objects.update(border.get_border())
def __init__(self, width, height, owner): ScreenGUI.__init__(self, width, height, owner) border = Border(width, height) self.buttons = Enum("BARCODE", "DESCRIPTION", "PRICE", "DONE", "CANCEL") # # # # Fixed position objects # # minx = border.inner_x() + 4 * Widths.BORDER maxx = width - Widths.BORDER miny = border.inner_y() + 4 * Widths.BORDER maxy = height - Widths.BORDER buttonh = 50 buttonw = 100 fullwidth = maxx - minx self.default_text = { self.buttons.BARCODE : "1. Scan an item", self.buttons.DESCRIPTION : "2. Type a description", self.buttons.PRICE : "3. Set a price", } self.objects = { self.buttons.BARCODE : LCARSCappedBar(pygame.Rect(minx, miny, fullwidth, buttonh), CapLocation.CAP_LEFT + CapLocation.CAP_RIGHT, "1. Scan an item", Colours.ENTRY, Colours.BG, True), self.buttons.DESCRIPTION : LCARSCappedBar(pygame.Rect(minx, miny + (2 * buttonh), fullwidth, buttonh), CapLocation.CAP_LEFT + CapLocation.CAP_RIGHT, "2. Type a description", Colours.ERR, Colours.BG, True), self.buttons.PRICE : LCARSCappedBar(pygame.Rect(minx, miny + (4 * buttonh), fullwidth, buttonh), CapLocation.CAP_LEFT + CapLocation.CAP_RIGHT, "3. Set a price", Colours.ERR, Colours.BG, True), self.buttons.DONE : LCARSCappedBar(pygame.Rect(minx, maxy - buttonh, buttonw, buttonh), CapLocation.CAP_LEFT + CapLocation.CAP_RIGHT, "Done", Colours.FG, Colours.BG, True), self.buttons.CANCEL : LCARSCappedBar(pygame.Rect(maxx - buttonw, maxy - buttonh, buttonw, buttonh), CapLocation.CAP_LEFT + CapLocation.CAP_RIGHT, "Cancel", Colours.FG, Colours.BG, True), } # # # # Import standard objects # # self.objects.update(border.get_border())
class IntroScreenGUI(ScreenGUI): """ Describes the graphical elements of the intro screen and provides methods for setting introduction text """ def __init__(self, width, height, owner): ScreenGUI.__init__(self, width, height, owner) self.border = Border(width, height) ## ## Fixed position objects ## self.path = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) # script directory self.objects = { 'titleimage' : LCARSImage(pygame.Rect(width/2, height*3/5, 0, 0), self.path + LOGO_PATH, True), } ## ## Import standard objects self.objects.update(self.border.get_border()) ## ## Position-dependant objects ## self.set_intro_text("Searching for remote database...", Colours.FG) self.set_intro_text_2("Don't have a card? Seeing error messages?", Colours.FG) self.set_intro_text_3("Pop money in the pot instead!", Colours.FG) def set_intro_text(self, text, color): """ The intro text is positioned centrally between the sweep and image """ text_y_position = (self.border.inner_y() + self.objects['titleimage'].t()) / 2 self.objects['introtext'] = LCARSText((self.width/2, text_y_position), text, 36, TextAlign.XALIGN_CENTRE, color, Colours.BG, True) def set_intro_text_2(self, text, color): """ The intro text is positioned between the image and the base """ text_y_position = (self.objects['titleimage'].b() + self.border.bottom()) / 2 text_y_position = text_y_position - 30 self.objects['introtext2'] = LCARSText((self.width/2, text_y_position), text, 36, TextAlign.XALIGN_CENTRE, color, Colours.BG, True) def set_intro_text_3(self, text, color): """ The intro text is positioned between the image and the base """ text_y_position = self.objects['introtext2'].t() + 80 self.objects['introtext3'] = LCARSText((self.width/2, text_y_position), text, 36, TextAlign.XALIGN_CENTRE, color, Colours.BG, True) def draw(self, window): """ Draw the screen objects on the supplied window """ window.fill(Colours.BG) for draw_obj in self.objects.values(): draw_obj.draw(window) #Ensure text is drawn on top self.objects['introtext'].draw(window) self.objects['introtext2'].draw(window) self.objects['introtext3'].draw(window) if self.banner is not None: self.banner.draw(window) pygame.display.flip()
class IntroScreenGUI(ScreenGUI): """ Describes the graphical elements of the intro screen and provides methods for setting introduction text """ def __init__(self, width, height, owner): ScreenGUI.__init__(self, width, height, owner) self.border = Border(width, height) ## ## Fixed position objects ## self.path = os.path.dirname( os.path.abspath(inspect.getfile( inspect.currentframe()))) # script directory self.objects = { 'titleimage': LCARSImage(pygame.Rect(width / 2, height * 3 / 5, 0, 0), self.path + LOGO_PATH, True), } ## ## Import standard objects self.objects.update(self.border.get_border()) ## ## Position-dependant objects ## self.set_intro_text("Searching for remote database...", Colours.FG) self.set_intro_text_2("Don't have a card? Seeing error messages?", Colours.FG) self.set_intro_text_3("Pop money in the pot instead!", Colours.FG) def set_intro_text(self, text, color): """ The intro text is positioned centrally between the sweep and image """ text_y_position = (self.border.inner_y() + self.objects['titleimage'].t()) / 2 self.objects['introtext'] = LCARSText( (self.width / 2, text_y_position), text, 36, TextAlign.XALIGN_CENTRE, color, Colours.BG, True) def set_intro_text_2(self, text, color): """ The intro text is positioned between the image and the base """ text_y_position = (self.objects['titleimage'].b() + self.border.bottom()) / 2 text_y_position = text_y_position - 30 self.objects['introtext2'] = LCARSText( (self.width / 2, text_y_position), text, 36, TextAlign.XALIGN_CENTRE, color, Colours.BG, True) def set_intro_text_3(self, text, color): """ The intro text is positioned between the image and the base """ text_y_position = self.objects['introtext2'].t() + 80 self.objects['introtext3'] = LCARSText( (self.width / 2, text_y_position), text, 36, TextAlign.XALIGN_CENTRE, color, Colours.BG, True) def draw(self, window): """ Draw the screen objects on the supplied window """ window.fill(Colours.BG) for draw_obj in self.objects.values(): draw_obj.draw(window) #Ensure text is drawn on top self.objects['introtext'].draw(window) self.objects['introtext2'].draw(window) self.objects['introtext3'].draw(window) if self.banner is not None: self.banner.draw(window) pygame.display.flip()