class Field(object): def __init__(self, value=None, style=None, box=None, format=None, width=72, height=11): self.value = value self.width = width self.height = height if style: self.style = style else: self.style = Style() if box: self.box = box else: self.box = Box() if format: self.format = format else: self.format = format_plain #------------------------------------------------------------------Set Size def set_size(self, width, height): self.width = width self.height = height #-----------------------------------------------------------------Get Width def get_width(self, canvas): text = self.format(self.value) return self.style.get_width(canvas, text) #----------------------------------------------------------------Get Height def get_height(self): return self.style.get_height() #------------------------------------------------------------Get Dimensions def get_dimensions(self, canvas): width = self.get_width(canvas) height = self.get_height() return width,height #----------------------------------------------------------------------Draw def draw(self, canvas, x, y): text = self.format(self.value) self.box.draw(canvas, x, y, self.width, self.height) self.style.draw(canvas, text, x, y, self.width, self.height)
def __init__(self, value=None, style=None, box=None, format=None, width=72, height=11): self.value = value self.width = width self.height = height if style: self.style = style else: self.style = Style() if box: self.box = box else: self.box = Box() if format: self.format = format else: self.format = format_plain
#------------------------------------------------------------------------------ # file: podunk/prefab/boxes.py # author: Jim Storch #------------------------------------------------------------------------------ from podunk.widget.box import Box from podunk.prefab import color from podunk.prefab import line #---------------------------------------------------------------------Blank Box BLANK_BOX = Box() #-------------------------------------------------------------------Grey Square GREY_SQUARE = Box() GREY_SQUARE.left_border = 1 GREY_SQUARE.top_border = 1 GREY_SQUARE.right_border = 1 GREY_SQUARE.bottom_border = 1 GREY_SQUARE.background_color = color.LIGHT_GREY #----------------------------------------------------------------------Thin Box THIN_BOX = Box() THIN_BOX.left_border = .25 THIN_BOX.top_border = .25 THIN_BOX.right_border = .25 THIN_BOX.bottom_border = .25 #-----------------------------------------------------------------Dotted Bottom