Lable Change by HAL Radio Button?

More
05 Feb 2016 14:06 #69651 by Todd Zuercher

I am also curious what you are doing as your 'jog' commands seem to actually just move the origin using g10?

Chris M


That is right, It is just a easy (for the operator not for me) way for the operator to make simple incremental adjustments to the G54 machine coordinate system, rather than use the "touchoff system" This is much simpler for the way we use this machine. (It is for a gang router that is used for engraving multiple items.)

I've already made a similar pyvcp panel (and a huge pile of halui commands and subroutines) for another of our carving machines. This time I wanted to try glade which removed the need for halui and most of the subs, but the python part is kicking my butt.

Please Log in or Create an account to join the conversation.

More
05 Feb 2016 14:36 #69652 by Todd Zuercher
That did the trick for me. (other than a couple of typos).

Now on to the next battle, I want to make the large ZW change depending on the state of a hal pin.
If false I'd like it to be black and ZW, if true blue and ZZ.
class HandlerClass:
    def __init__(self, halcomp,builder,useropts):
        self.builder = builder
        self.jog_increment = self.builder.get_object('jog_increment')
        self.g54inch = self.builder.get_object('g54inch_jog')
        self.g54tenth = self.builder.get_object('g54tenth_jog')
        self.g54hundredth = self.builder.get_object('g54hundedth_jog')
        self.g54thousandth = self.builder.get_object('g54thousandth_jog')

    def activ_inc(self, widget):
        if widget.get_active():
            if widget == self.g54inch: self.jog_increment.set_text('1.000')
            elif widget == self.g54tenth: self.jog_increment.set_text('0.100')
            elif widget == self.g54hundredth: self.jog_increment.set_text('0.010')
            elif widget == self.g54thousandth: self.jog_increment.set_text('0.001')

# This is boiler code, required for gladevcp
def get_handlers(halcomp,builder,useropts):
    return [HandlerClass(halcomp,builder,useropts)]

Please Log in or Create an account to join the conversation.

More
06 Feb 2016 02:16 - 06 Feb 2016 02:17 #69687 by cmorley
import hal_glib
import hal
import pango

class HandlerClass:
    def __init__(self, halcomp,builder,useropts):
        self.builder = builder
        self.halcomp = halcomp
        self.jog_increment = self.builder.get_object('jog_increment')
        self.g54inch = self.builder.get_object('g54inch_jog')
        self.g54tenths = self.builder.get_object('g54tenth_jog')
        self.g54hundredths = self.builder.get_object('g54hundedth_jog')
        self.g54thousandths = self.builder.get_object('g54thousandth_jog')
        self.z_label = self.builder.get_object('z_label')
        self.w_label = self.builder.get_object('w_label')
        self.example_trigger = hal_glib.GPin(halcomp.newpin('label-trigger', hal.HAL_BIT, hal.HAL_IN))
        self.example_trigger.connect('value-changed', self.on_label_trigger_value_changed)

        self.attr_true = pango.AttrList()       
        fg_color = pango.AttrForeground(65535, 0, 0, 0, -1)
        size = pango.AttrSize(30000, 0, -1)
        weight = pango.AttrWeight(pango.WEIGHT_BOLD, 0, -1)
        self.attr_true.insert(fg_color)
        self.attr_true.insert(size)
        self.attr_true.insert(weight)

        self.attr_false = pango.AttrList()       
        fg_color = pango.AttrForeground(0, 0, 0, 0, -1)
        self.attr_false.insert(fg_color)
        self.attr_false.insert(size)
        self.attr_false.insert(weight)

    def on_label_trigger_value_changed(self, pin):
        state = pin.get()
        if state:
            self.z_label.set_attributes(self.attr_true)
            self.w_label.set_attributes(self.attr_true)
        else:
            self.z_label.set_attributes(self.attr_false)
            self.w_label.set_attributes(self.attr_false)

    def activ_inc(self, widget):
        if widget.get_active():
            if widget == self.g54inch: self.jog_increment.set_text('1.000')
            elif widget == self.g54tenths: self.jog_increment.set_text('0.100')
            elif widget == self.g54hundedths:  self.jog_increment.set_text('0.010')
            elif widget == self.g54thousandths: self.jog_increment.set_text('0.001')

# This is boiler code, required for gladevcp
def get_handlers(halcomp,builder,useropts):
    return [HandlerClass(halcomp,builder,useropts)]


You should be able to change this to what you want

Chris M
Last edit: 06 Feb 2016 02:17 by cmorley.
The following user(s) said Thank You: Todd Zuercher

Please Log in or Create an account to join the conversation.

More
09 Feb 2016 15:32 - 09 Feb 2016 16:49 #69854 by Todd Zuercher
Thanks alot. Here is what I think I'll end up using.
import hal_glib
import hal
import pango

class HandlerClass:
    def __init__(self, halcomp,builder,useropts):
        self.builder = builder
        self.halcomp = halcomp
        self.jog_increment = self.builder.get_object('jog_increment')
        self.g54inch = self.builder.get_object('g54inch_jog')
        self.g54tenths = self.builder.get_object('g54tenth_jog')
        self.g54hundredths = self.builder.get_object('g54hundedth_jog')
        self.g54thousandths = self.builder.get_object('g54thousandth_jog')
        self.zw_label = self.builder.get_object('zw_label')
        self.example_trigger = hal_glib.GPin(halcomp.newpin('label-trigger', hal.HAL_BIT, hal.HAL_IN))
        self.example_trigger.connect('value-changed', self.on_label_trigger_value_changed)

        self.attr_true = pango.AttrList()       
        fg_color = pango.AttrForeground(0, 0, 65535, 0, -1)
        size = pango.AttrSize(30000, 0, -1)
        weight = pango.AttrWeight(pango.WEIGHT_BOLD, 0, -1)
        self.attr_true.insert(fg_color)
        self.attr_true.insert(size)
        self.attr_true.insert(weight)

        self.attr_false = pango.AttrList()       
        fg_color = pango.AttrForeground(0, 0, 0, 0, -1)
        self.attr_false.insert(fg_color)
        self.attr_false.insert(size)
        self.attr_false.insert(weight)

    def on_label_trigger_value_changed(self, pin):
        state = pin.get()
        if state:
            self.zw_label.set_attributes(self.attr_true)
            self.zw_label.set_text('ZZ')
        else:
            self.zw_label.set_attributes(self.attr_false)
            self.zw_label.set_text('ZW')

    def activ_inc(self, widget):
        if widget.get_active():
            if widget == self.g54inch: self.jog_increment.set_text('1.000')
            elif widget == self.g54tenths: self.jog_increment.set_text('0.100')
            elif widget == self.g54hundredths:  self.jog_increment.set_text('0.010')
            elif widget == self.g54thousandths: self.jog_increment.set_text('0.001')

# This is boiler code, required for gladevcp
def get_handlers(halcomp,builder,useropts):
    return [HandlerClass(halcomp,builder,useropts)]
Attachments:
Last edit: 09 Feb 2016 16:49 by Todd Zuercher.

Please Log in or Create an account to join the conversation.

More
10 Feb 2016 01:35 #69897 by cmorley
glad your getting closer to your goal!

Chris M

Please Log in or Create an account to join the conversation.

Moderators: mhaberlerHansU
Time to create page: 0.159 seconds
Powered by Kunena Forum