So I have a graph tool of sorts using a PyQt5 gui, and giving the user the ability to color nodes and name them. But you can imagine that depending on what color you color the nodes, the text can be illegible. So if there was a way to get a black border on a QFont, then I can have text white and have it show up well over anything. Is this possible given the framework?
I'm also open to any solution that solves the problem of being able to read text over any color as well. Thank you.
Edit:
from PyQt5 import QtGui, QtWidgets
class MyPushButton(QtWidgets.QPushButton):
def __init__(self, text):
super(MyPushButton, self).__init__()
self.setFixedHeight(50)
self.font = QtGui.QFont()
self.setupFont()
self.setFont(self.font)
self.setStyleSheet('color: white; background-color: yellow')
self.setText(text)
self.clicked.connect(self.change_color)
def change_color(self):
color = QtWidgets.QColorDialog.getColor()
if color.isValid():
self.setStyleSheet('color: white;background-color:' + color.name())
def setupFont(self):
self.font.setFamily('Palatino')
self.font.setPointSize(20)
# some other font manipulations
if __name__ == '__main__':
import sys
app = QtWidgets.QApplication(sys.argv)
widget = QtWidgets.QWidget()
layout = QtWidgets.QVBoxLayout()
push1 = MyPushButton('test text 1')
layout.addWidget(push1)
push2 = MyPushButton('test text 2')
layout.addWidget(push2)
widget.setLayout(layout)
widget.show()
sys.exit(app.exec_())
I want: