def __init__(self, parent=None):
super(MySlider, self).__init__(parent)
def paintEvent(self, event):
"""Paint log scale ticks"""
super(MySlider, self).paintEvent(event)
pen.setWidth(2)
pen.setColor(Qt.black)
qp.setPen(pen)
font
= QFont('Times',
10) font_y_offset = font.pointSize()/2
qp.setFont(font)
size = self.size()
contents = self.contentsRect()
db_val_list = [10, 5, 0, -5, -10, -20, -30, -40, -50, -60, -90]
for val in db_val_list:
if val == 10:
y_val_fudge = 12
elif val == -90:
y_val_fudge = -12
db_scaled = db_to_int(val)
y_val = contents.height() - translate(db_scaled, 0, 1023, 0, contents.height())
if val == -90:
qp.drawText(contents.x() - font.pointSize(), y_val + font_y_offset + y_val_fudge, '-oo')
else:
qp.drawText(contents.x() - font.pointSize(), y_val + font_y_offset + y_val_fudge,'{0:2}'.format(val))
qp.drawLine(contents.x() + font.pointSize(), y_val + y_val_fudge, contents.x() + contents.width(), y_val + y_val_fudge)
class MySlider(QtWidgets.QSlider):
def __init__(self, parent=None):
super(MySlider, self).__init__(parent)
def paintEvent(self, event):
"""Paint log scale ticks"""
super(MySlider, self).paintEvent(event)
qp = QPainter(self)
pen = QPen()
pen.setWidth(2)
pen.setColor(Qt.black)
qp.setPen(pen)
font = QFont('Times', 10)
font_y_offset = font.pointSize()/2
qp.setFont(font)
size = self.size()
contents = self.contentsRect()
db_val_list = [10, 5, 0, -5, -10, -20, -30, -40, -50, -60, -90]
for val in db_val_list:
if val == 10:
y_val_fudge = 12
elif val == -90:
y_val_fudge = -12
db_scaled = db_to_int(val)
y_val = contents.height() - translate(db_scaled, 0, 1023, 0, contents.height())
if val == -90:
qp.drawText(contents.x() - font.pointSize(), y_val + font_y_offset + y_val_fudge, '-oo')
else:
qp.drawText(contents.x() - font.pointSize(), y_val + font_y_offset + y_val_fudge,'{0:2}'.format(val))
qp.drawLine(contents.x() + font.pointSize(), y_val + y_val_fudge, contents.x() + contents.width(), y_val + y_val_fudge)
To copy to clipboard, switch view to plain text mode
Bookmarks