当前位置: 首页>>代码示例>>Python>>正文


Python Monitor.get方法代码示例

本文整理汇总了Python中monitor.Monitor.get方法的典型用法代码示例。如果您正苦于以下问题:Python Monitor.get方法的具体用法?Python Monitor.get怎么用?Python Monitor.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在monitor.Monitor的用法示例。


在下文中一共展示了Monitor.get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setup

# 需要导入模块: from monitor import Monitor [as 别名]
# 或者: from monitor.Monitor import get [as 别名]
def setup():
    Monitor.get().start();
    screen = Gdk.Screen.get_default();
    for i in xrange(0, screen.get_n_monitors()):
        # setup for each monitor
        rect = screen.get_monitor_geometry(i);
        config.config_monitor(i, rect);
开发者ID:xinhaoyuan,项目名称:rmdock,代码行数:9,代码来源:entry.py

示例2: config_monitor

# 需要导入模块: from monitor import Monitor [as 别名]
# 或者: from monitor.Monitor import get [as 别名]
def config_monitor(mid, rect):
    from meter import Meter;
    from widget.linear_meter import LinearMeterWidget;
    from widget.circle_meter import CircleMeterWidget;
    from widget.surface import SurfaceWidget;
    from widget.pango import PangoWidget;
    from monitor import Monitor;
    from datetime import datetime;
    import math;
    import cairo;

    c = Meter(300, 300);
    c.add_widget(LinearMeterWidget(LambdaMonitor(lambda : Monitor.get().cpu_usage), 
                                   145, 6, color = (1,1,1), alpha = 0.5,
                                   gravity = LinearMeterWidget.GRAVITY_EAST),
                 145, 300, 1, 1);
    c.add_widget(LinearMeterWidget(LambdaMonitor(lambda : Monitor.get().pmem_usage),
                                   145, 6, color = (1,1,1), alpha = 0.5,
                                   gravity = LinearMeterWidget.GRAVITY_WEST),
                 155, 300, -1, 1);
    c.add_widget(CircleMeterWidget(LambdaMonitor(lambda : (datetime.now().time().hour % 12) / 12.0), 
                                   140, 6, -math.pi / 2 + math.pi / 10, -math.pi / 2 - math.pi / 10,
                                   color=(1,1,1), alpha = 0.5, style = CircleMeterWidget.STYLE_SEGMENT),
                 150, 150, 0, 0);
    c.add_widget(CircleMeterWidget(LambdaMonitor(lambda : datetime.now().time().minute / 60.0 + datetime.now().time().second / 3600.0),
                                   128, 10, -math.pi / 2, -math.pi / 2,
                                   color=(1,1,1), alpha = 0.5),
                 150, 150, 0, 0);
    c.add_widget(CircleMeterWidget(LambdaMonitor(lambda : datetime.now().time().second / 60.0),
                                   112, 10, -math.pi / 2 - math.pi / 10, -math.pi / 2 + math.pi / 10,
                                   style=CircleMeterWidget.STYLE_SEGMENT, color=(1,1,1), alpha = 0.5), 
                 150, 150, 0, 0);
    c.add_widget(PangoWidget(LambdaMonitor(lambda :
                                           "<span font='Monospace 25'>" + datetime.now().strftime("%H%M%S") + "</span>\n" +
                                           "<span font='Monospace 20'>" + datetime.now().strftime("%y%m%d") + "</span>"),
                             color=(1,1,1), alpha = 0.5, alignment = "center"), 
                 150, 150, 0, 0);
            
    c.add_widget(PangoWidget(LambdaMonitor(lambda :
                                           "<span font='Monospace 20'>" + str(Monitor.get().gmail_unread_count) + "</span>"),
                             color=(1,1,1), alpha = 0.5, alignment = "center"), 
                 gmail_icon.get_width(), 0, -1, -1);

    c.add_widget(SurfaceWidget(gmail_icon, gmail_icon.get_width(), gmail_icon.get_height()),
                 0, 0, -1, -1);

    c.get_window().move(rect.x + (rect.width - c.width) / 2,
                        rect.y + (rect.height - c.height) / 2);
    c.show();
开发者ID:xinhaoyuan,项目名称:rmdock,代码行数:51,代码来源:config_example.py

示例3: draw

# 需要导入模块: from monitor import Monitor [as 别名]
# 或者: from monitor.Monitor import get [as 别名]
  def draw(self, cr):
    now = datetime.datetime.now()
    time = now.time();
    hour_12 = time.hour % 12;
    min_60 = time.minute;
    sec_60 = time.second;

    width = self.meter.width;
    height = self.meter.height;
    if (height > width):
      radius = width / 2 - self.meter.padding;
    else:
      radius = height / 2 - self.meter.padding;
    hour_r = self.meter.hour_radius;
    min_r = self.meter.min_radius;
    sec_r = self.meter.sec_radius;
    padding = self.meter.padding;

    # hour
    cr.new_path();
    angle_h = -math.pi / 2 + math.pi / 6 * hour_12;
    cr.arc(width / 2, height / 2, radius - hour_r - padding, angle_h + math.pi / 30, angle_h - math.pi / 30);
    cr.set_line_width(hour_r * 2);
    cr.set_source_rgba(self.meter.fill_color[0], self.meter.fill_color[1], self.meter.fill_color[2], self.meter.opacity);
    cr.stroke();
    # min
    cr.new_path();
    cr.arc(width / 2, height / 2, radius - hour_r * 2 - padding * 2 - min_r, -math.pi / 2, -math.pi / 2 + math.pi / 1800 * (min_60 * 60 + sec_60));
    cr.set_line_width(min_r * 2);
    cr.set_source_rgba(self.meter.fill_color[0], self.meter.fill_color[1], self.meter.fill_color[2], self.meter.opacity);
    cr.stroke();
    # sec
    cr.new_path();
    angle_s = -math.pi / 2 + math.pi / 30 * sec_60;
    cr.arc(width / 2, height / 2, radius - (hour_r + min_r) * 2 - padding * 3 - sec_r, angle_s - math.pi / 10, angle_s + math.pi / 10);
    cr.set_line_width(sec_r * 2);
    cr.set_source_rgba(self.meter.fill_color[0], self.meter.fill_color[1], self.meter.fill_color[2], self.meter.opacity);
    cr.stroke();
    # text
    pangocairo_context = pangocairo.CairoContext(cr)
    pangocairo_context.set_antialias(cairo.ANTIALIAS_SUBPIXEL)
    layout = pangocairo_context.create_layout();
    layout.set_alignment("center");
    layout.set_markup("<span font='Monospace 24'>" + time.strftime("%H%M%S") + "</span>\n" + 
                      "<span font='Monospace 20'>" + now.strftime("%y%m%d") + "</span>");
    size = layout.get_pixel_size();
    cr.move_to((width - size[0]) / 2, (height - size[1]) / 2);
    cr.set_source_rgba(self.meter.fill_color[0], self.meter.fill_color[1], self.meter.fill_color[2], self.meter.opacity);
    pangocairo_context.update_layout(layout);
    pangocairo_context.show_layout(layout);

    # gmail count
    if (self.gmail_icon_surface == None):
      image_surface = cairo.ImageSurface.create_from_png(path + "/img/gmail-icon-i.png");
      data = bytearray(image_surface.get_data());
      for y in xrange(0, image_surface.get_height()):
        for x in xrange(0, image_surface.get_width()):
          pos = y * image_surface.get_stride() + x * 4;
          data[pos] /= 2
          data[pos + 1] /= 2;
          data[pos + 2] /= 2;
          data[pos + 3] /= 2;
      self.gmail_icon_surface = cairo.ImageSurface.create_for_data(data, image_surface.get_format(), image_surface.get_width(), image_surface.get_height(), image_surface.get_stride());
      image_surface.finish();
                      
    cr.move_to(0,0);
    cr.set_source_surface(self.gmail_icon_surface);
    cr.paint();

    layout.set_alignment("left");
    layout.set_markup("<span font='Monospace 20'>" + str(Monitor.get().gmail_unread_count) + "</span>");
    cr.move_to(self.gmail_icon_surface.get_width(), 0);
    cr.set_source_rgba(self.meter.fill_color[0], self.meter.fill_color[1], self.meter.fill_color[2], self.meter.opacity);
    pangocairo_context.update_layout(layout);
    pangocairo_context.show_layout(layout);

    # fill the left bar with cpu usage
    if (self.left_fill_path == None):
      cr.new_path();
      cr.move_to(width / 2 - padding, height);
      cr.arc(width / 2, height / 2, radius, math.pi / 2 + math.asin(float(padding) / radius), math.pi - math.asin(float(radius - padding * 2) / radius));
      cr.line_to(0, height / 2 + radius - padding * 2);
      cr.line_to(0, height);
      cr.close_path();
      self.left_fill_path = cr.copy_path();
    else:
      cr.new_path();
      cr.append_path(self.left_fill_path);

    cr.save();
    cr.set_source_rgba(1,1,1,0.1);
    cr.fill_preserve();
    cr.clip();
    bar_length = (width / 2 - padding) * (Monitor.get().cpu_usage);
    cr.rectangle((width / 2 - padding) - bar_length, height / 2, bar_length, height / 2);
    cr.set_source_rgba(self.meter.fill_color[0], self.meter.fill_color[1], self.meter.fill_color[2], self.meter.opacity);
    cr.fill();
    cr.restore();

    # fill the right bar with cpu usage
#.........这里部分代码省略.........
开发者ID:xinhaoyuan,项目名称:rmdock,代码行数:103,代码来源:meter_example.py

示例4: get

# 需要导入模块: from monitor import Monitor [as 别名]
# 或者: from monitor.Monitor import get [as 别名]
 def get(self):
   return Monitor.get().cpu_usage;
开发者ID:xinhaoyuan,项目名称:rmdock,代码行数:4,代码来源:meter_example.py


注:本文中的monitor.Monitor.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。