Exemple #1
0
    def __init__(self,
                 file,
                 parent='osd',
                 text=' ',
                 left=None,
                 top=None,
                 width=500,
                 height=350,
                 bg_color=None,
                 fg_color=None,
                 icon=None,
                 border=None,
                 bd_color=None,
                 bd_width=None):

        handler = None
        self.file = file
        self.filetext = open(self.file, 'rb').read()

        PopupBox.__init__(self, text, handler, top, left, width, height, icon,
                          None, None, parent)

        myfont = self.osd.getfont(config.OSD_DEFAULT_FONTNAME,
                                  config.OSD_DEFAULT_FONTSIZE)
        surf_w = myfont.stringsize('AAAAAAAAAA' * 8)
        data = self.osd.drawstringframed(self.filetext,
                                         0,
                                         0,
                                         surf_w,
                                         1000000,
                                         myfont,
                                         align_h='left',
                                         align_v='top',
                                         fgcolor=self.osd.COL_BLACK,
                                         mode='hard',
                                         layer='')[1]
        (ret_x0, ret_y0, ret_x1, ret_y1) = data
        surf_h = ret_y1 - ret_y0
        if height > surf_h:
            surf_h = height
        surf = pygame.Surface((surf_w, surf_h), 0, 32)
        bg_c = self.bg_color.get_color_sdl()
        surf.fill(bg_c)
        self.osd.drawstringframed(self.filetext,
                                  0,
                                  0,
                                  surf_w,
                                  surf_h,
                                  myfont,
                                  align_h='left',
                                  align_v='top',
                                  fgcolor=self.osd.COL_BLACK,
                                  mode='hard',
                                  layer=surf)
        self.pb = RegionScroller(surf, 50, 50, width=width, height=height)
        self.add_child(self.pb)
Exemple #2
0
    def __init__(self, lines, file=None, parent='osd', text=' ', left=None, top=None, width=500,
                 height=350, bg_color=None, fg_color=None, icon=None,
                 border=None, bd_color=None, bd_width=None):
        """
        Initialise a LogScroll instance

        @param left:      x coordinate. Integer
        @param top:       y coordinate. Integer
        @param width:     Integer
        @param height:    Integer
        @param text:      String to print.
        @param bg_color:  Background color (Color)
        @param fg_color:  Foreground color (Color)
        @param icon:      icon
        @param border:    Border
        @param bd_color:  Border color (Color)
        @param bd_width:  Border width Integer
        """

        handler = None
        self.lines = file is not None and open(file, 'rb').read() or lines

        PopupBox.__init__(self, text, handler, top, left, width, height, icon, None, None, parent)

        myfont = self.osd.getfont(config.OSD_DEFAULT_FONTNAME, config.OSD_DEFAULT_FONTSIZE)
        import pprint
        pprint.pprint(myfont.__dict__)
        surf_w = myfont.stringsize('AAAAAAAAAA'*8)
        data = self.osd.drawstringframed('\n'.join(self.lines), 0, 0, surf_w, 1000000, myfont,
            align_h='left', align_v='top', fgcolor=self.osd.COL_BLACK, mode='hard', layer='')[1]
        (ret_x0,ret_y0, ret_x1, ret_y1) = data
        surf_h = ret_y1 - ret_y0
        if height>surf_h:
            surf_h=height
        surf = pygame.Surface((surf_w, surf_h), 0, 32)
        bg_c = self.bg_color.get_color_sdl()
        surf.fill(bg_c)
        y = 0
        for line in self.lines:
            colour = self.osd.COL_BLACK
            if line.startswith('<so> '):
                colour = self.osd.COL_WHITE
            elif line.startswith('<se> '):
                colour = self.osd.COL_ORANGE
            line = line[4:]
            self.osd.drawstringframed(line, 0, y, surf_w, surf_h, myfont, align_h='left', align_v='top',
            fgcolor=colour, mode='hard', layer=surf)
            #y += myfont.ptsize + 1
            y += myfont.height
        self.pb = RegionScroller(surf, 50, 50, width=width, height=height)
        self.add_child(self.pb)
Exemple #3
0
    def __init__(self, loglines, logfilename, parent='osd', text=None, handler=None, left=None,
        top=None, width=600, height=300, bg_color=None, fg_color=None,
        icon=None, border=None, bd_color=None, bd_width=None,
        vertical_expansion=1):

        if not text:
            text = _('Command finished')

        PopupBox.__init__(self, text, handler, top, left, width, height, icon, vertical_expansion, None, parent)

        items_height = 40
        self.loglines = loglines
        self.logfilename = logfilename
        self.num_shown_items = 2
        self.results = ListBox(width=(self.width-2*self.h_margin), height=self.num_shown_items*items_height,
            show_v_scrollbar=0)
        self.results.y_scroll_interval = self.results.items_height = items_height

        self.add_child(self.results)
        self.results.add_item(text=_('OK'), value='ok')
        if loglines or logfilename:
            self.results.add_item(text=_('Show output'), value='out')
        self.results.toggle_selected_index(0)
Exemple #4
0
    def __init__(self,
                 parent='osd',
                 text=None,
                 handler=None,
                 left=None,
                 top=None,
                 width=600,
                 height=300,
                 bg_color=None,
                 fg_color=None,
                 icon=None,
                 border=None,
                 bd_color=None,
                 bd_width=None,
                 vertical_expansion=1):

        if not text:
            text = _('Command finished')

        #PopupBox.__init__(self, text, handler=handler, x=top, y=left, width=width, height=height)
        PopupBox.__init__(self, text, handler, top, left, width, height, icon,
                          vertical_expansion, None, parent)

        items_height = 40
        self.num_shown_items = 3
        self.results = ListBox(width=(self.width - 2 * self.h_margin),
                               height=self.num_shown_items * items_height,
                               show_v_scrollbar=0)
        self.results.y_scroll_interval = self.results.items_height = items_height

        self.add_child(self.results)
        self.results.add_item(text=_('OK'), value='ok')
        if islog('err'):
            self.results.add_item(text=_('Show Stderr'), value='err')
        if islog('out'):
            self.results.add_item(text=_('Show Stdout'), value='out')
        self.results.toggle_selected_index(0)