def __changeDirectory(self, path): for c in self.filesview: c.setParent(None) c.deleteLater() self.filesview = [] self.checkBox_2.setChecked(False) self.progressBars = {} for f in self.__getFiles(path): try: group = QGroupBox(f, self) group.setGeometry(QRect(20, 20, 100, 150)) group.setCheckable(True) group.setChecked(False) group.setFixedSize(100, 150) group.setFlat(True) group.setToolTip(f) label = QLabel(group) label.setScaledContents(True) label.setGeometry(QRect(5, 25, 90, 90)) label.setToolTip(f) progressBar = QProgressBar(group) progressBar.setGeometry(QRect(0, 70, 111, 10)) progressBar.setProperty("value", 0) progressBar.setTextVisible(False) progressBar.setToolTip('0%') progressBar.setVisible(False) self.progressBars[f] = progressBar self.filesview.append(group) from os.path import isfile if isfile(path + '/' + f): ext = f.split('.')[-1] if isfile('icons/' + ext.lower() + '.png'): label.setPixmap( QPixmap('icons/' + ext.lower() + '.png')) else: label.setPixmap(QPixmap('icons/default.png')) else: label.setPixmap(QPixmap('icons/folder.png')) self.connect(group, SIGNAL("clicked()"), self.__deselectFile) except ValueError: pass i = 0 for x in list(range(len(self.filesview))): if (x % 4) == 0: i = i + 1 self.rowsview[i].addWidget(self.filesview[x])
def createMetricTools(self): ''' Called once countThread is over. ''' if not self.configuration: # First, create configuration dictionary i = 0 for timeFamily, timeList in self.timeline.timeMap.items(): if len(timeList): # One sub dictionary per time family self.configuration.append([timeFamily, []]) for oneMetric in timeList: # One sub sub dictionary per family sub time # checked indicate if item is displayed # color indicate which color to use if i < len(self.timeline.colors): self.configuration[-1][1].append([oneMetric, [['checked', True], ['color', self.timeline.colors[i][0]], ['checkBox', None], ['colorWidget', None], ['colorWidgetIndex', -1], ['orderedNodeList', {'dates':None, 'nodes':None}], ['dateLimits', [long(0), long(0xffffffffffffffff)]], ['mainPixmap', [True, None]], ['zoomPixmap', [True, None]]]]) else: self.configuration[-1][1].append([oneMetric, [['checked', False], ['color', ''], ['checkBox', None], ['colorWidget', None], ['colorWidgetIndex', -1], ['orderedNodeList', {'dates':None, 'nodes':None}], ['dateLimits', [long(0), long(0xffffffffffffffff)]], ['mainPixmap', [True, None]], ['zoomPixmap', [True, None]]]]) i += 1 else: self.configuration.append([timeFamily, []]) # Configuration object created, now create graphical view of it # self.dumpOptionsConf() i = 0 for family in self.configuration: if family[1]: box = QGroupBox(family[0]) oneTime = QVBoxLayout() for time in family[1]: hbox = QHBoxLayout() time[1][2][1] = QCheckBox(':'.join(time[0])) self.connect(time[1][2][1], SIGNAL("stateChanged(int)"), self.checkboxClick) time[1][3][1] = QComboBox() for color in self.timeline.colors: time[1][3][1].addItem(color[0]) palette = time[1][2][1].palette() if i < len(self.timeline.colors): time[1][2][1].setChecked(time[1][0][1]) # Colorize foreground palette.setColor(QPalette.WindowText, self.timeline.colors[i][1]) time[1][3][1].setCurrentIndex(i) time[1][4][1] = i else: # In case every colors are already used, don't check time (default) and don't select any color palette.setColor(QPalette.WindowText, Qt.gray) time[1][0][1] = False time[1][3][1].setEnabled(False) time[1][2][1].setPalette(palette) self.connect(time[1][3][1], SIGNAL("currentIndexChanged(const QString&)"), self.colorChange) hbox.addWidget(time[1][2][1]) hbox.addWidget(time[1][3][1]) oneTime.addLayout(hbox) i += 1 box.setLayout(oneTime) optimum = box.minimumSizeHint() box.setFixedSize(optimum) if optimum.width() > self.familyLayout.sizeHint().width(): geom = QRect(0, 0, optimum.width(), self.familyLayout.sizeHint().height() + optimum.height()) else: geom = QRect(0, 0, self.familyLayout.sizeHint().width(), self.familyLayout.sizeHint().height() + optimum.height()) self.familyLayout.addWidget(box) self.familyLayout.setGeometry(geom) self.familyWidget.setFixedSize(geom.width(), geom.height()) self.familyScroll.setWidget(self.familyWidget) else: # Configuration object already created, we are called because am item has been # unchecked or its color has changed. pass
def createMetricTools(self): ''' Called once countThread is over. ''' if not self.configuration: # First, create configuration dictionary i = 0 for timeFamily, timeList in self.timeline.timeMap.items(): if len(timeList): # One sub dictionary per time family self.configuration.append([timeFamily, []]) for oneMetric in timeList: # One sub sub dictionary per family sub time # checked indicate if item is displayed # color indicate which color to use if i < len(self.timeline.colors): self.configuration[-1][1].append([ oneMetric, [['checked', True], ['color', self.timeline.colors[i][0]], ['checkBox', None], ['colorWidget', None], ['colorWidgetIndex', -1], [ 'orderedNodeList', { 'dates': None, 'nodes': None } ], [ 'dateLimits', [long(0), long(0xffffffffffffffff)] ], ['mainPixmap', [True, None]], ['zoomPixmap', [True, None]]] ]) else: self.configuration[-1][1].append([ oneMetric, [['checked', False], ['color', ''], ['checkBox', None], ['colorWidget', None], ['colorWidgetIndex', -1], [ 'orderedNodeList', { 'dates': None, 'nodes': None } ], [ 'dateLimits', [long(0), long(0xffffffffffffffff)] ], ['mainPixmap', [True, None]], ['zoomPixmap', [True, None]]] ]) i += 1 else: self.configuration.append([timeFamily, []]) # Configuration object created, now create graphical view of it # self.dumpOptionsConf() i = 0 for family in self.configuration: if family[1]: box = QGroupBox(family[0]) oneTime = QVBoxLayout() for time in family[1]: hbox = QHBoxLayout() time[1][2][1] = QCheckBox(':'.join(time[0])) self.connect(time[1][2][1], SIGNAL("stateChanged(int)"), self.checkboxClick) time[1][3][1] = QComboBox() for color in self.timeline.colors: time[1][3][1].addItem(color[0]) palette = time[1][2][1].palette() if i < len(self.timeline.colors): time[1][2][1].setChecked(time[1][0][1]) # Colorize foreground palette.setColor(QPalette.WindowText, self.timeline.colors[i][1]) time[1][3][1].setCurrentIndex(i) time[1][4][1] = i else: # In case every colors are already used, don't check time (default) and don't select any color palette.setColor(QPalette.WindowText, Qt.gray) time[1][0][1] = False time[1][3][1].setEnabled(False) time[1][2][1].setPalette(palette) self.connect( time[1][3][1], SIGNAL("currentIndexChanged(const QString&)"), self.colorChange) hbox.addWidget(time[1][2][1]) hbox.addWidget(time[1][3][1]) oneTime.addLayout(hbox) i += 1 box.setLayout(oneTime) optimum = box.minimumSizeHint() box.setFixedSize(optimum) if optimum.width() > self.familyLayout.sizeHint().width(): geom = QRect( 0, 0, optimum.width(), self.familyLayout.sizeHint().height() + optimum.height()) else: geom = QRect( 0, 0, self.familyLayout.sizeHint().width(), self.familyLayout.sizeHint().height() + optimum.height()) self.familyLayout.addWidget(box) self.familyLayout.setGeometry(geom) self.familyWidget.setFixedSize(geom.width(), geom.height()) self.familyScroll.setWidget(self.familyWidget) else: # Configuration object already created, we are called because am item has been # unchecked or its color has changed. pass