How to modify, and use Hal_ LED color
10 Aug 2021 01:46 #217354
by yi2580
How to modify, and use Hal_ LED color was created by yi2580
I am using Python and GTK to write a GUI interface. Now I want to use an LED light in the interface to display a signal transmitted from the IO serial port. What should I do? This problem has plagued me for a long time and has not been solved. I hope someone can help me
thank you
thank you
Please Log in or Create an account to join the conversation.
10 Aug 2021 02:01 #217355
by yi2580
Replied by yi2580 on topic How to modify, and use Hal_ LED color
I use the Hal LED component in Hal python. I want to modify its color in the interface and how I should use it. For example, when a signal comes in, it changes from green to red.
Please Log in or Create an account to join the conversation.
10 Aug 2021 02:16 #217359
by cmorley
Replied by cmorley on topic How to modify, and use Hal_ LED color
Are you using GLADE editor for the GUI or coding the GUI with python?
This gives some details about the LED widget:
linuxcnc.org/docs/devel/html/gui/gladevcp.html#gladevcp:hal-led
Usually on would set the colors in the GLADE file but you can also use properties in python:
[widget name].set_property("on_color","blue")
This gives some details about the LED widget:
linuxcnc.org/docs/devel/html/gui/gladevcp.html#gladevcp:hal-led
Usually on would set the colors in the GLADE file but you can also use properties in python:
[widget name].set_property("on_color","blue")
Please Log in or Create an account to join the conversation.
10 Aug 2021 02:49 #217362
by yi2580
Replied by yi2580 on topic How to modify, and use Hal_ LED color
Hello, thank you very much for your reply
I use the glade editor as the GUI. After reading the links you sent, I have a general understanding, but how can I establish a relationship between my trigger signal and the lighting of the LED?
I use the glade editor as the GUI. After reading the links you sent, I have a general understanding, but how can I establish a relationship between my trigger signal and the lighting of the LED?
Please Log in or Create an account to join the conversation.
10 Aug 2021 02:54 #217364
by cmorley
Replied by cmorley on topic How to modify, and use Hal_ LED color
If you trigger signal is HAL based:
Make sure the 'create_hal_pin' property is true and then a HAL pin will be made that you can connect to and control the LED
otherwise use the python code:
[widgetname].set_active(True)
Make sure the 'create_hal_pin' property is true and then a HAL pin will be made that you can connect to and control the LED
otherwise use the python code:
[widgetname].set_active(True)
Please Log in or Create an account to join the conversation.
10 Aug 2021 04:53 #217369
by yi2580
Replied by yi2580 on topic How to modify, and use Hal_ LED color
Hello!
I used your code, but he gave me the error
" pin0.set_active(On)
NameError: global name 'pin0' is not defined"
I'm not sure how to define pin0
on_ pinb_ Clicked is my button
Pin0 is the name of my Hal LED light
I used your code, but he gave me the error
" pin0.set_active(On)
NameError: global name 'pin0' is not defined"
I'm not sure how to define pin0
on_ pinb_ Clicked is my button
Pin0 is the name of my Hal LED light
Please Log in or Create an account to join the conversation.
10 Aug 2021 05:02 #217372
by cmorley
Replied by cmorley on topic How to modify, and use Hal_ LED color
you would need to post the whole python file so i can see what you are doing.
Please Log in or Create an account to join the conversation.
10 Aug 2021 05:19 #217373
by yi2580
Replied by yi2580 on topic How to modify, and use Hal_ LED color
Hello!
The whole Python file may be a little big. I'll send the Python code I'm using now. Please help me have a look,The picture below is my glade interface
What I want to do is that I click the button and the LED light will change color, or a signal defined in Hal can change the LED color. I don't know how to do it. I don't quite understand how to configure my Hal file to make the LED color change, or how to program in Python
Thank you very much for taking the trouble to answer my questions。
The whole Python file may be a little big. I'll send the Python code I'm using now. Please help me have a look,
def on_pinb_clicked(self,widget, data=None):
print'pinb'
pin0.set_active(True)
What I want to do is that I click the button and the LED light will change color, or a signal defined in Hal can change the LED color. I don't know how to do it. I don't quite understand how to configure my Hal file to make the LED color change, or how to program in Python
Thank you very much for taking the trouble to answer my questions。
Please Log in or Create an account to join the conversation.
10 Aug 2021 05:39 #217375
by cmorley
Replied by cmorley on topic How to modify, and use Hal_ LED color
You are making it difficult for me to help you.
I need to see your python file so I can see what code to use to reference the pin0
usually it's something like:
self.builder.get_object("pin0').set_active(True)
But there are other ways to reference widgets.
I need to see your python file so I can see what code to use to reference the pin0
usually it's something like:
self.builder.get_object("pin0').set_active(True)
But there are other ways to reference widgets.
Please Log in or Create an account to join the conversation.
10 Aug 2021 05:48 #217376
by yi2580
Replied by yi2580 on topic How to modify, and use Hal_ LED color
Oh, thank you very much for your answer. I haven't quoted pi0. It may be ridiculous. Now it's OK,
Thank you very much for answering my questions. You make me enlightened
Thank you very much for answering my questions. You make me enlightened
Please Log in or Create an account to join the conversation.
Moderators: HansU
Time to create page: 0.097 seconds