fbpx

CS-Lab Support Forum for CNC Community

Help to run this brand-new forum and stay with us.
Ask your questions, we are here to help! 

 

Please or Register to create posts and topics.

Python CSS

How can I change the CSS properties of a widget at runtime from a Python script?
Specifically, I want to change the background colour of a LineEdit widget when a certain case occurs and also reset it later.

This is done using the "setAttribute" function.
To make it possible, you need to know the ID of the object you want to change the color of. The ID can be found in the GUI editor.

Here is an example of changing the font color and size:
gui.edJogStep.setAttribute("styleSheet", "background-color: red; font-size: 24px;")

“edJogStep” is the ID of the object.

Anton has reacted to this post.
Anton

Thank you very much for the quick answer.
I had tried it as you showed, only I had css as the attribute name and not sylesheet.

Here you will find the concrete application (spindel warm up):
https://cncwerk.de/forum/viewtopic.php?f=6&t=2755&start=10
VG

dylan1024 has reacted to this post.
dylan1024

Great!
We are pleased when users customize simCNC for their own needs.
This develops the forum, which is a knowledge base for others.

Made a little movie about copying functionality and GUI from one screen to another.
Maybe it will help someone.
https://youtu.be/-IFiFhVwRAk

 

CS-Lab Support and dylan1024 have reacted to this post.
CS-Lab Supportdylan1024

Super video!
It's great that you show it to others.

PARTNERS:

 

USA

Germany

Slovenia / Bosnia

Spain

South Africa

UNI-CAM

The Netherlands

Portugal

Greece

  Distrib milionis logo

Hungary

Distrib logot

Bulgaria

Master

Kenya

Proteq Automation

Egypt

Germanelectronix

China

Jun Ma

Serbia

ALCO

Italy

LVL tech r

Denmark

Varntoft Dania

Finland

×

Hello!

Click one of our contacts below to chat on WhatsApp

× How can I help you?