Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009 from __future__ import division
00010
00011 from python_qt_binding.QtCore import QSize
00012 from python_qt_binding.QtGui import QIcon, QPixmap, QStandardItem, QHBoxLayout, QLabel, QTextEdit, QSizePolicy, QFont
00013
00014
00015
00016
00017 class QRappItem(QStandardItem):
00018 def __init__(self, rapp, running):
00019 QStandardItem.__init__(self, rapp['display_name'])
00020 self.setSizeHint(QSize(100,100))
00021 icon = get_qicon(rapp['icon'])
00022 self.setIcon(icon)
00023 f = QFont()
00024 f.setPointSize(10)
00025 self.setFont(f)
00026 self.setToolTip(rapp['description'])
00027 self.setEditable(False)
00028 self.setRapp(rapp)
00029 self.setEnabled(running)
00030
00031 def compare_name(self, display_name, name):
00032 if self._rapp['display_name'] == display_name and self._rapp['name'] == name:
00033 return True
00034 else:
00035 return False
00036
00037 def setRapp(self, rapp):
00038 self._rapp = rapp
00039 def getRapp(self):
00040 return self._rapp
00041
00042
00043
00044
00045 def get_qicon(icon):
00046 pixmap = QPixmap()
00047 pixmap.loadFromData(icon.data, format=icon.format)
00048 return QIcon(pixmap)
00049
00050 def get_qpixmap(icon):
00051 pixmap = QPixmap()
00052 pixmap.loadFromData(icon.data, format=icon.format)
00053 return pixmap
00054
00055 def create_label_textedit_pair(key, value):
00056 '''
00057 Probabaly there should be better way to lay out param and remappings
00058 '''
00059
00060 name = QLabel(key)
00061 name.setToolTip(key)
00062 name.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Preferred)
00063 name.setMinimumWidth(400)
00064 name.setMaximumHeight(30)
00065 name.setWordWrap(True)
00066
00067 textedit = QTextEdit()
00068 textedit.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Preferred)
00069 textedit.setMinimumWidth(320)
00070 textedit.setMaximumHeight(30)
00071 textedit.append(str(value))
00072 return name, textedit
00073
00074 def create_label(name, is_bold=False):
00075 qname = QLabel(name)
00076 f = QFont()
00077 f.setBold(is_bold)
00078 qname.setFont(f)
00079 return qname