Exemple #1
0
 def redraw_fore(self, ctx):
     #!get radians
     _cpu = cpu_x()
     _cpu_start = self.cpu_start * (math.pi / 180)
     _cpu_end = self.cpu_end * (math.pi / 180)
     #!org /100
     _cpu_r = ((_cpu_end - _cpu_start) / 50 * _cpu) + _cpu_start - math.pi
     _mem = mem_x()
     _mem_start = self.mem_start * (math.pi / 180)
     _mem_end = self.mem_end * (math.pi / 180)
     _mem_r = ((_mem_end - _mem_start) / 100 * _mem) + _mem_start - math.pi
     #!draw context
     ctx.save()
     ctx.translate(self.cpu_dial_x, self.cpu_dial_y)
     ctx.scale(0.8, 0.8)
     ctx.rotate(_cpu_r)
     self.__window.render(ctx, 'clock-hour-hand')
     ctx.restore()
     ctx.save()
     ctx.translate(self.mem_dial_x, self.mem_dial_y)
     ctx.scale(0.4, 0.4)
     ctx.rotate(_mem_r)
     self.__window.render(ctx, 'clock-hour-hand')
     ctx.restore()
     ctx.save()
     ctx.translate(*self.skin_xy)
     self.__window.render(ctx, 'cpumeter-dot')
     ctx.restore()
Exemple #2
0
    def redraw_fore(self, ctx):
        x, y = 0, 100
        w, h = self.__window.width, 100

        _txt = self.__window.dtime.strftime("%A %d %B")
        ctx.set_source_rgba(*self._fgc)
        self.__window.draw_text(ctx, self._font, _txt, x, y, w, 0, 1)

        _cx, _mx = cpu_x(), mem_x()
        _txt = "cpu %s%% : mem %s%%" % (_cx, _mx)
        ctx.set_source_rgba(*self._fgc)
        self.__window.draw_text(ctx, self._font, _txt, x, y + 13, w, 0, 1)

        x, y = 12, 110
        if _cx < 2 or _cx > 100: _cx = 2
        ctx.set_source_rgba(0.4, 0.4, 0.4, 1.0)  #!empty
        self.__window.draw_line(ctx, x, y, w - (x * 2), 0, 1)
        ctx.set_source_rgba(*self._fgc)  #!fill
        self.__window.draw_line(ctx, x, y, int(_cx * (w - (x * 2)) / 100), 0,
                                1)