Resources

To create a resources.py file with images to use with the .qss stylesheet, start by placing all the images in a different directory than the configuration files. A subdirectory in the configuration directory is fine

└── configs
   └── my_mill
       └── images

Add the following library if not installed

sudo apt install qtbase5-dev-tools

After installing Flex GUI on the CNC menu run Flex Resources

_images/resources-00.png

Startup

_images/resources-01.png

Next Select Images Directory

_images/resources-02.png

The selected directory is shown in the label

_images/resources-03.png

Next Select Image Files. To select all the images left click on the first one and hold down the shift key and left click on the last one. To pick several images but not all hold down the ctrl key while you left click on each one.

_images/resources-04.png

The images selected are shown below

_images/resources-05.png

Next Build QRC File

_images/resources-06.png

Next Select Config Directory

_images/resources-07.png

Note

The Image directory and the configuration directory must be different

Next Build Resources File

_images/resources-08.png

The Flex Resourse Builder can be closed now. In the configuration directory you will have a resources.py file that contains the images used by the stylesheet.

Next edit the ini file and in the [FLEX] section add the following line

RESOURCES = resources.py

In the [DISPLAY] section add the style sheet

QSS = xyz.qss

To add an image named my-image.png to a QPushButton with an object name of my_pb add the following to the qss file

QPushButton#my_pb {
        min-height: 80px;
        min-width: 80px;
        margin: 2px;
        background-position: center;
        background-origin: content;
        background-clip: padding;
        background-repeat: no-repeat;
        background-image: url(:my-image.png);
}

Now when you run the configuration the image will be on the QPushButton

_images/resources-09.png

Note

Delete any text in the QPushButton or it will be on top of the image