def insert_navigation(self, button1_text=None, button2_text=None, button3_text=None, default=None): ''' Inserts navigation buttons starting from the leftmost button ''' nbw = 90 nbh = 24 sep_top = 6 sep_height = 2 if hasattr(self, "vertical_image"): sep_top = 0 self.navigation = ui.Panel( self, 0, self.height - nbh - 20 - sep_top - sep_height, self.width, nbh + 20 + sep_top + sep_height) if not hasattr(self, "vertical_image"): self.revision_label = ui.Label(self.navigation, 10, 0, 40, 20, "Rev %s" % self.info.revision) self.revision_label.disable() self.line = ui.EtchedRectangle(self.navigation, 50, sep_top, self.width - 60, sep_height) else: self.line = ui.EtchedRectangle(self.navigation, 0, sep_top, self.width, sep_height) for i, text in enumerate((button1_text, button2_text, button3_text)): if not text: continue if default and i + 1 == default: Button = ui.DefaultButton else: Button = ui.Button n = 0 for other in (button1_text, button2_text, button3_text)[i:]: if other: n += 1 button = Button(self.navigation, self.width - (nbw + 10) * n, 10 + sep_top + sep_height, nbw, nbh, text=text) if default and i + 1 == default: button.set_focus() setattr(self.navigation, "button%s" % (i + 1), button) self.navigation.height = nbh + 20 + sep_top + sep_height
def insert_header(self, title, subtitle, bmp_file): ''' Inserts a header with image, title and subtitle ''' hbh = 57 hbw = 150 self.header = ui.Panel( self, 0, 0 , self.width, hbh+2) if bmp_file: self.header.image = ui.Bitmap( self.header, 0, 0, hbw, hbh) self.header.image.set_image( os.path.join(unicode(str(self.info.image_dir), 'mbcs'), unicode(str(bmp_file), 'mbcs'))) if title: self.header.title = ui.Label( self.header, hbw + 20, 10, self.width - 200, 16, text = title) self.header.title.set_font(bold=True) if subtitle: self.header.subtitle = ui.Label( self.header, hbw + 20, 26, self.width - 200, 26, text = subtitle) self.header.line = ui.EtchedRectangle(self.header,0, hbh,self.width, 2) self.header.height = hbh + 2 self.header.set_background_color(255,255,255)