Exemple #1
0
    def __init__(self,  var_dict):
        #Width and height will be set once font is rendered
        GuiObject.__init__(self, var_dict)
        self.type = TEXT

        try:
            self.font_size = var_dict['font_size']
            self.text = var_dict['text']
            self.font_color = var_dict['font_color']
            if 'watch' not in var_dict:
                self.watch_func = None
            else:
                self.watch_func = var_dict['watch']
        except KeyError:
            print('Not all required arguments passed to GuiText')
            raise

        self.font = pygame.font.SysFont("Calibri", self.font_size)

        to_display = self.text
        if callable(self.watch_func):
            to_display += self.watch_func()
        self.font_img = self.font.render(to_display, True, self.font_color)

        self.rect.w, self.rect.h = self.font.size(self.text)
Exemple #2
0
 def __init__(self, var_dict):
     GuiObject.__init__(self, var_dict)
     self.type = WINDOW
     try:
         self.rect.w = var_dict['w']
         self.rect.h = var_dict['h']
         self.bg_color = var_dict['bg_color']
     except KeyError:
         print("Not all required arguments given to GuiWindow")
         raise
Exemple #3
0
    def __init__(self, var_dict):
        GuiObject.__init__(self, var_dict)
        self.text = ""
        self.img = None
        self.type = TXT_BOX
        self.changed = True
        self.font = pygame.font.SysFont("Calibri", 18)

        try:
            self.bg_color = var_dict['bg_color']
        except KeyError:
            print("Not all required arguments given to Textbox")
            raise
Exemple #4
0
    def __init__(self, var_dict):
        GuiObject.__init__(self, var_dict)
        self.items_dict = {}
        self.type = LIST_BOX
        try:
            self.bg_color = var_dict['bg_color']
            if 'items_list' in var_dict:
                self.update_list(var_dict['items_list'], True)
        except KeyError:
            print("Not all required argumennts given to GuiListbox")
            raise

        self.selected = 0
        self.rows = 10
        #index of middle item in entire items_dict
        self.top_index = 0
Exemple #5
0
    def __init__(self, var_dict):
        GuiObject.__init__(self, var_dict)
        self.type = BUTTON
        try:
            self.font_size = var_dict['font_size']
            self.font_color = var_dict['font_color']
            self.text = var_dict['text']
            self.action = var_dict['action']
            self.bg_color = var_dict['bg_color']
            #boolean value that determines if the controlling gui state should be closed on button press
            self.close_state = var_dict['close_state']
        except KeyError:
            print('Not all required arguments passed to GuiButton')
            raise

        self.font = pygame.font.SysFont("Calibri", self.font_size)
        self.font_img = self.font.render(self.text, True, self.font_color)
        size = self.font.size(self.text)
        self.rect.w = size[0] + (self.margin * 2)
        self.rect.h = size[1] + (self.margin * 2)