forked from LinuxCNC/linuxcnc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmeter_scale.py
More file actions
27 lines (20 loc) · 898 Bytes
/
meter_scale.py
File metadata and controls
27 lines (20 loc) · 898 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import linuxcnc
import os
import hal
import hal_glib
class HandlerClass:
def _on_max_value_change(self,hal_pin,data=None):
self.meter.max = float(hal_pin.get())
self.meter.queue_draw() # force a widget redraw
def __init__(self, halcomp,builder,useropts):
self.builder = builder
# hal pin with change callback.
# When the pin's value changes the callback is executed.
self.max_value = hal_glib.GPin(halcomp.newpin('max-value', hal.HAL_FLOAT, hal.HAL_IN))
self.max_value.connect('value-changed', self._on_max_value_change)
inifile = linuxcnc.ini(os.getenv("INI_FILE_NAME"))
mmax = inifile.getreal("METER", "MAX", fallback=100.0)
self.meter = self.builder.get_object('meter')
self.max_value.set(mmax)
def get_handlers(halcomp,builder,useropts):
return [HandlerClass(halcomp,builder,useropts)]