SourceForge.net Logo

CGRU

LinkedIn
Since 1.6.7 (at 2012.12.03) site moved to cgru.info

Afanasy Custom Resources


You can write custom resources meter(s) on Python. Render instances a class and runs update method periodically (each time the Render updates). You can inherit base resbase class and set its properties.

To make render to use you python class, list names in configuration file in render_resclasses parameter. There are some examples of custom meters in Afanasy.

  • example - Just an example. It increments a value from 0 to 100, changes label text, plotter and label size, graph and back color.
  • iostat - Shows parsed output of linux 'iostat' command. Graph value is utilization percentage (or %busy).

This is how Watch shows two custom resources meters example and iostat.
render_rescustom.png
It places custom plotters in a second row, under standard build-in resources meters.

Python classes stored in
cgru/afanasy/python/resources
and based from
cgru/afanasy/python/resources/resbase.py

Properties:

  • self.value (int) - The resource value to watch.
  • self.valuemax (int) - Maximum resource value for graph scale.
  • self.height (int) - Preferred plotter widget height for GUI.
  • self.width (int) - Preferred plotter widget width for GUI.
  • self.graphr self.graphrg self.graphb (int) - Graph color.
  • self.label (str) - Label text.
  • self.labelsize (int) - Label text font size.
  • self.labelr self.labelg self.labelb (int) - Label text font color.
  • self.bgcolorr self.bgcolorg self.bgcolorb (int) - Plotter background color.
  • self.tooltip (str) - Widget tooltip.
  • self.valid (False|True) - Resource meter validness. Should be set to True in constructor, or update function will not be called. Set False if resource meter initialization failed.

Since 1.6.7 (at 2012.12.03) site moved to cgru.info
SourceForge.net Project

CGRU

Libre Graphics World