Label

  • BigJohnT
  • BigJohnT's Avatar Topic Author
  • Offline
  • Administrator
  • Administrator
More
08 Jan 2012 14:29 #16439 by BigJohnT
Label was created by BigJohnT
I'm building my GladeVCP panel for the BP and I'm wondering if you can have a label that changes the text based on an input. For example if the spindle is off display OFF, if running in the forward direction display FWD, and if running in reverse display REV.

Is this possible?

Thanks
John

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

More
08 Jan 2012 15:31 - 08 Jan 2012 17:36 #16442 by ArcEye
Replied by ArcEye on topic Re:Label
Hi John

The answer is basically an event handler

www.linuxcnc.org/docview/devel/html/gui/...user_defined_actions

seems to cover it in respect of glade and there is even an example for changing label text based upon button presses.

This is the same way C/C++ gui programs work, pressing or checking something creates an event and handlers are written and linked to those events to perform the required actions.

emc2_2.5xxx/configs/gladevcp/complex also shows an example

Anything more detailed best ask Michael H, I am trying to keep away from python, lest I scramble what my brain still remembers of C/C++ !!

regards
Last edit: 08 Jan 2012 17:36 by ArcEye.

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

More
09 Jan 2012 09:49 #16467 by mhaberler
Replied by mhaberler on topic Re:Label
BigJohnT wrote:

I'm building my GladeVCP panel for the BP and I'm wondering if you can have a label that changes the text based on an input. For example if the spindle is off display OFF, if running in the forward direction display FWD, and if running in reverse display REV.

Is this possible?


Yes, it is.

The basic scheme is:

- define a HAL pin with halcomp.newpin()
- associate a 'value-changed' handler with that pin, which will be called when the HAL pin's value is changed
- in that handler, set the widget as appropriate,

I suggest you look at the configs/gladevcp/complex example, the example_trigge pin shows how to do it.
Let me know if it works out, otherwise I'll cook up an example

-Michael

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

More
09 Jan 2012 10:39 #16469 by andypugh
Replied by andypugh on topic Re:Label
mhaberler wrote:

- associate a 'value-changed' handler with that pin, which will be called when the HAL pin's value is changed
- in that handler, set the widget as appropriate, l


Is there no standard widget that will do this? It sounds like a combo-box but in reverse, where an input integer chooses from a list of entries (whereas with a combo-box choosing an entry sets an integer output).

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

More
09 Jan 2012 11:21 - 09 Jan 2012 11:24 #16470 by dab77
Replied by dab77 on topic Re:Label
Hal_label has already in-pin, so maybe you can send a number to that pin and in python convert the number to a string with a 'case' or 'if' statement. could it be?
in your case if speed is 0 then label.in is 0 -> text is 'STOP' or whatelse.
label.in<0 -> text is 'REV'
label.in>0 -> text is 'FWD'.

Davide.
Last edit: 09 Jan 2012 11:24 by dab77.

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

More
09 Jan 2012 11:49 #16472 by mhaberler
Replied by mhaberler on topic Re:Label
here is a complete example how to do it.

git.mah.priv.at/gitweb/emc2-dev.git/shor...s/heads/custom-label

-Michael

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

  • BigJohnT
  • BigJohnT's Avatar Topic Author
  • Offline
  • Administrator
  • Administrator
More
09 Jan 2012 13:42 #16478 by BigJohnT
Replied by BigJohnT on topic Re:Label
Michael,

Thanks so much for the example... examples help a lot when your new and confused. I'll get this tried out this afternoon.

I'm really liking GladeVCP and have figured most things out by reading the manual.

Thanks
John

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

  • BigJohnT
  • BigJohnT's Avatar Topic Author
  • Offline
  • Administrator
  • Administrator
More
09 Jan 2012 14:40 - 09 Jan 2012 17:26 #16479 by BigJohnT
Replied by BigJohnT on topic Re:Label
Michael,

Thanks so much! I tested it out stand alone and it will work well for my configuration.

Thanks
John
Last edit: 09 Jan 2012 17:26 by BigJohnT.

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

  • BigJohnT
  • BigJohnT's Avatar Topic Author
  • Offline
  • Administrator
  • Administrator
More
09 Jan 2012 17:25 #16480 by BigJohnT
Replied by BigJohnT on topic Re:Label
Michael,

Thanks again! I got it working in my configuration and it is the neatest thing to see it... your example made the difference between many hours of pulling my hair out and getting it up and going in a hurry.

Thanks
John

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

More
09 Jan 2012 21:33 #16482 by mhaberler
Replied by mhaberler on topic Re:Label
I've updated the example to enable level-dependent background colors:

git.mah.priv.at/gitweb/emc2-dev.git/shor...s/heads/custom-label

-m

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

Moderators: HansU
Time to create page: 0.076 seconds
Powered by Kunena Forum