toxygen/src/widgets.py
2016-04-24 13:45:11 +03:00

24 lines
647 B
Python

from PySide import QtGui, QtCore
class DataLabel(QtGui.QLabel):
def paintEvent(self, event):
painter = QtGui.QPainter(self)
metrics = QtGui.QFontMetrics(self.font())
text = metrics.elidedText(self.text(), QtCore.Qt.ElideRight, self.width())
painter.drawText(self.rect(), self.alignment(), text)
class CenteredWidget(QtGui.QWidget):
def __init__(self):
super(CenteredWidget, self).__init__()
self.center()
def center(self):
qr = self.frameGeometry()
cp = QtGui.QDesktopWidget().availableGeometry().center()
qr.moveCenter(cp)
self.move(qr.topLeft())