2016-05-24 20:22:21 +02:00
|
|
|
try:
|
|
|
|
from PySide import QtCore, QtGui
|
|
|
|
except ImportError:
|
|
|
|
from PyQt4 import QtCore, QtGui
|
2016-04-24 12:45:11 +02:00
|
|
|
|
|
|
|
|
|
|
|
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())
|
2016-05-18 23:38:21 +02:00
|
|
|
|
|
|
|
|
|
|
|
class QRightClickButton(QtGui.QPushButton):
|
|
|
|
def __init__(self, parent):
|
|
|
|
super(QRightClickButton, self).__init__(parent)
|
|
|
|
|
|
|
|
def mousePressEvent(self, event):
|
|
|
|
if event.button() == QtCore.Qt.RightButton:
|
|
|
|
self.emit(QtCore.SIGNAL("rightClicked()"))
|
|
|
|
else:
|
|
|
|
super(QRightClickButton, self).mousePressEvent(event)
|