Esempio n. 1
0
def _make_listwidget_item(path, template_dir, temp_info):
    name = basename(path)
    full_path = join(get_mfix_templates(), template_dir, path)

    # extract info from the template info file
    info = temp_info.get(name, {})
    description = info.get('description', ' ' * 50)
    solver = info.get('solver', 'single')
    geo = info.get('geometry', 'false')
    chem = info.get('chemistry', 'false')

    # build a list of booleans for filtering templates
    # [single, tfm, pic, dem, hybrid, geometry, chemistry, tutorials, benchmarks, tests]
    template_classes = ['single', 'tfm', 'pic', 'dem', 'hybrid']
    enable_list = [solver == t for t in template_classes]
    enable_list.extend([i.lower() == 'true' for i in [geo, chem]])
    enable_list.extend(
        [template_dir == t for t in ['tutorials', 'benchmarks', 'tests']])

    name = '\n'.join([name, description])

    item = QListWidgetItem(get_thumbnail(full_path), name)
    item.full_path = full_path
    item.tags = [t for t in template_classes if solver == t]
    if geo.lower() == 'true':
        item.tags.append('geometry')
    if chem.lower() == 'true':
        item.tags.append('chemistry')
    item.template_dir = template_dir
    return item
Esempio n. 2
0
    def onClickItem(self, item):
        self.thumbnailList.clear()
        #a= TreeWidget(item.text(1))
        #self.middle.addWidget(ThumbnailPanel.createWidget(item.text(1)))
        folder = item.text(1)

        for root, dirs, files in os.walk(folder):
            for filename in files:
                if os.path.splitext(filename)[1] in ['.png', '.jpg']:
                    full_path = os.path.abspath(os.path.join(root, filename))

                    name = os.path.splitext(filename)[0].split('_')[0].replace(
                        '-', ' ').capitalize()
                    item = QListWidgetItem(name)
                    item.setIcon(QIcon(full_path))
                    item.full_path = full_path

                    self.thumbnailList.addItem(item)