Relative Content

Tag Archive for pyqt5

Making a non-rectangular button in PyQt5

I’m making a GUI using PyQt5 where I have hexagonal cells that have a button that is part of a circle at some vertex. However, I can’t find a way to make the clickable area of the button be the arc, and nothing but the arc. Even when I create a “slice” widget and paint it, there is either a clickable area outside of the slice (making a clickable area of a rectangle), or the clickable area is too small. How can I make a button of the correct shape?
Here is a stripped-down version of my code. The button position is determined by the channel_pos argument for the Hex class; 0 is the top vertex and they are numbered clockwise around the hexagon.

Accessing composite QWidget

My code creates a composite widget, it is made of a button and a label.
It is part of broader code where this composite widget is the element of a list.
But now let’s focus on my problem that is:
How do I get to know the text in QPushButton at runtime?
This is the code: