def paintEvent(self, event):
painter = QPainter(self)
painter.setRenderHint(QPainter.Antialiasing)
width = self.width() - 8
height = 36
previous = 0
percent_up = 0
for partition in self.partitions:
color = self.color_list[self.partitions.index(partition)]
percent = self.__percentage(width, partition.getSize(), self.max_capacity)
if percent < 10:
percent += 4
percent_up += 1
if percent_up >= 0 and percent >= width/35:
percent -= 4 * percent_up
percent_up = 0
print(percent, width)
painter.setPen(color)
painter.setBrush(color)
painter.drawRect(QRectF(4+previous, 5, percent, 34))
previous += percent
#Çerçeve
painter.setPen(QColor(Qt.black))
painter.setBrush(Qt.NoBrush)
painter.drawRoundedRect(QRectF(4, 4, width, height), 4, 4)
#Parlakl?k
painter.drawPixmap(QRect(6, 6, width-4, height-4), QPixmap(":/images/partitionwidget/light.svg"))
#kareler
line = 0
column = 0
for partition in self.partitions:
painter.setPen(Qt.black)
painter.setBrush(self.color_list[self.partitions.index(partition)])
if width - (line * 150) <= 150:
column += 1
line = 0
painter.drawRoundedRect(QRectF(4 + (line * 150), (column*32)+64, 12, 12), 2, 2)
painter.drawText(QRectF(24 + (line * 150), (column*32)+64, 30, 12),
Qt.AlignVCenter | Qt.TextDontClip, partition.path)
painter.setPen(Qt.darkGray)
if partition.fileSystem:
painter.drawText(QRectF(24 + (line * 150), (column*32)+78, 40, 12),
Qt.AlignVCenter | Qt.TextDontClip, "{} {}".format(mbToGB(partition.getSize()),
partition.fileSystem.type))
else:
painter.drawText(QRectF(24 + (line * 150), (column*32)+78, 40, 12),
Qt.AlignVCenter | Qt.TextDontClip,
self.tr("{} Bilinmiyor").format(mbToGB(partition.getSize())))
line += 1
评论列表
文章目录