コード例 #1
0
    def add_conf_group(self, conf_group_widget):
        row = conf_group_widget.childCount()

        conformer_item = QTreeWidgetItem(conf_group_widget)
        conf_group_widget.insertChild(row, conformer_item)

        nrg_combobox = FilereaderComboBox(self.session, otherItems=['energy'])
        nrg_combobox.currentIndexChanged.connect(
            lambda *args: self.changes.emit())
        freq_combobox = FilereaderComboBox(self.session,
                                           otherItems=['frequency'])
        freq_combobox.currentIndexChanged.connect(
            lambda *args: self.changes.emit())

        trash_button = QPushButton()
        trash_button.setFlat(True)
        trash_button.clicked.connect(
            lambda *args, combobox=nrg_combobox: combobox.deleteLater())
        trash_button.clicked.connect(
            lambda *args, combobox=freq_combobox: combobox.deleteLater())
        trash_button.clicked.connect(lambda *args, child=conformer_item:
                                     conf_group_widget.removeChild(child))
        trash_button.clicked.connect(lambda *args: self.changes.emit())
        trash_button.setIcon(
            QIcon(self.style().standardIcon(QStyle.SP_DialogCancelButton)))

        self.tree.setItemWidget(conformer_item, 0, nrg_combobox)
        self.tree.setItemWidget(conformer_item, 1, freq_combobox)
        self.tree.setItemWidget(conformer_item, 2, trash_button)

        self.changes.emit()
コード例 #2
0
    def __init__(self, name, session, nrg_fr, thermo_co, size, *args,
                 **kwargs):
        super().__init__(*args, **kwargs)

        self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)

        self.session = session
        self.nrg_fr = nrg_fr
        self.thermo_co = thermo_co

        layout = QGridLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setRowStretch(0, 1)

        frame = QGroupBox(name)
        frame.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        frame_layout = QGridLayout(frame)
        frame_layout.setContentsMargins(0, 0, 0, 0)
        frame_layout.setRowStretch(0, 1)

        self.tree = QTreeWidget()
        self.tree.setColumnCount(3)
        self.tree.setHeaderLabels(["energy", "frequencies", "remove"])
        self.tree.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.tree.setColumnWidth(0, size[0])
        self.tree.setColumnWidth(1, size[1])
        self.tree.resizeColumnToContents(2)

        root_item = self.tree.invisibleRootItem()
        plus = QTreeWidgetItem(root_item)
        plus_button = QPushButton("add molecule")
        plus_button.setFlat(True)
        plus_button.clicked.connect(self.add_mol_group)
        plus_button2 = QPushButton("")
        plus_button2.setFlat(True)
        plus_button2.clicked.connect(self.add_mol_group)
        self.tree.setItemWidget(plus, 0, plus_button)
        self.tree.setItemWidget(plus, 1, plus_button2)
        self.tree.insertTopLevelItem(1, plus)

        self.add_mol_group()

        frame_layout.addWidget(self.tree)

        layout.addWidget(frame)
コード例 #3
0
 def __init__(self, scene, name, parent=None):
     super(UIPinGroup, self).__init__(parent)
     self.setAcceptHoverEvents(True)
     self.borderPen = QtGui.QPen(Colors.DarkGray, 0.5, QtCore.Qt.SolidLine)
     self._scene = scene
     self.layout = QGraphicsLinearLayout(QtCore.Qt.Vertical)
     self.layout.setContentsMargins(0, 0, 0, 0)
     self.layout.setSpacing(NodeDefaults().LAYOUTS_SPACING)
     self.setLayout(self.layout)
     headerBtn = QPushButton(name)
     headerBtn.setStyleSheet(headerBtnStyle)
     headerBtn.setFlat(True)
     headerBtn.setContentsMargins(0, 0, 0, 0)
     headerBtn.setMaximumHeight(10)
     headerBtn.clicked.connect(self.toggleCollapsed)
     self.headerWidget = self._scene.addWidget(headerBtn)
     self.layout.addItem(self.headerWidget)
     self._pins = set()
     self.bCollapsed = False
コード例 #4
0
def get_button(button_type):
    button = QPushButton()
    button.setFlat(True)
    if button_type == "success":
        button.setIcon(button.style().standardIcon(
            QStyle.SP_DialogApplyButton))
    elif button_type == "fail":
        button.setIcon(button.style().standardIcon(
            QStyle.SP_MessageBoxCritical))
    elif button_type == "error":
        button.setIcon(button.style().standardIcon(
            QStyle.SP_MessageBoxWarning))
    elif button_type == "skip" or button_type == "expected fail":
        button.setIcon(button.style().standardIcon(
            QStyle.SP_MessageBoxInformation))
    elif button_type == "unexpected success":
        button.setIcon(button.style().standardIcon(
            QStyle.SP_MessageBoxQuestion))

    return button
コード例 #5
0
    def add_mol_group(self, *args):
        row = self.tree.topLevelItemCount()

        root_item = self.tree.invisibleRootItem()

        mol_group = QTreeWidgetItem(root_item)
        self.tree.insertTopLevelItem(row, mol_group)
        trash_button = QPushButton()
        trash_button.setFlat(True)

        trash_button.clicked.connect(
            lambda *args, parent=mol_group: self.remove_mol_group(parent))
        trash_button.setIcon(
            QIcon(self.style().standardIcon(QStyle.SP_DialogDiscardButton)))

        add_conf_button = QPushButton("add conformer")
        add_conf_button.setFlat(True)
        add_conf_button.clicked.connect(
            lambda *args, conf_group_widget=mol_group: self.add_conf_group(
                conf_group_widget))

        add_conf_button2 = QPushButton("")
        add_conf_button2.setFlat(True)
        add_conf_button2.clicked.connect(
            lambda *args, conf_group_widget=mol_group: self.add_conf_group(
                conf_group_widget))

        add_conf_child = QTreeWidgetItem(mol_group)
        self.tree.setItemWidget(add_conf_child, 0, add_conf_button)
        self.tree.setItemWidget(add_conf_child, 1, add_conf_button2)
        self.tree.setItemWidget(mol_group, 2, trash_button)

        mol_group.setText(0, "group %i" % row)

        mol_group.addChild(add_conf_child)
        self.add_conf_group(mol_group)

        self.tree.expandItem(mol_group)

        self.changes.emit()
コード例 #6
0
    def __init__(self, parent=None):
        QMainWindow.__init__(self, parent)

        self.data = ParticleData()

        toolbar = self.addToolBar("Test")

        openButton = QPushButton("")
        openButton.setFlat(True)
        openButton.setIconSize(QSize(32, 32))
        openButton.setIcon(QIcon("/jobs2/soft/icons/dlight/open.png"))
        openButton.setToolTip("Open File")
        toolbar.addWidget(openButton)
        openButton.clicked.connect(self.openSlot)
        QShortcut(QKeySequence(Qt.CTRL + Qt.Key_O), self, self.openSlot)

        saveButton = QPushButton("")
        saveButton.setFlat(True)
        saveButton.setIconSize(QSize(32, 32))
        saveButton.setIcon(QIcon("/jobs2/soft/icons/dlight/file_save.png"))
        saveButton.setToolTip("Save File")
        toolbar.addWidget(saveButton)
        saveButton.clicked.connect(self.saveSlot)
        QShortcut(QKeySequence(Qt.CTRL + Qt.Key_S), self, self.saveSlot)

        saveDeltaButton = QPushButton("")
        saveDeltaButton.setFlat(True)
        saveDeltaButton.setIconSize(QSize(32, 32))
        saveDeltaButton.setIcon(
            QIcon("/jobs2/soft/icons/dlight/file_save_as.png"))
        saveDeltaButton.setToolTip("Save File As Delta")
        toolbar.addWidget(saveDeltaButton)
        saveDeltaButton.clicked.connect(self.saveDeltaSlot)
        QShortcut(QKeySequence(Qt.CTRL + Qt.SHIFT + Qt.Key_S), self,
                  self.saveDeltaSlot)

        addParticleButton = QPushButton("Particle")
        addParticleButton.setFlat(True)
        addParticleButton.setIconSize(QSize(32, 32))
        addParticleButton.setIcon(QIcon("/jobs2/soft/icons/shared/plus.png"))
        addParticleButton.setToolTip("Add Particle")
        toolbar.addWidget(addParticleButton)
        addParticleButton.clicked.connect(self.addParticleSlot)

        addAttributeButton = QPushButton("Attribute")
        addAttributeButton.setFlat(True)
        addAttributeButton.setIconSize(QSize(32, 32))
        addAttributeButton.setIcon(QIcon("/jobs2/soft/icons/shared/plus.png"))
        addAttributeButton.setToolTip("Add Attribute")
        toolbar.addWidget(addAttributeButton)
        addAttributeButton.clicked.connect(self.addAttributeSlot)

        splitter = QSplitter(self)
        self.setCentralWidget(splitter)

        particleTable = ParticleTableWidget(self.data, self)
        splitter.addWidget(particleTable)

        right = QWidget(self)
        splitter.addWidget(right)
        vbox = QVBoxLayout(right)
        right.setLayout(vbox)

        fixedAttrWidget = FixedAttributesWidget(self.data, self)
        vbox.addWidget(fixedAttrWidget)

        indexedStrings = IndexedStringsWidget(self.data, self)
        vbox.addWidget(indexedStrings)

        vbox.addStretch()

        # TODD: SCROLLABLE AREAS FOR EVERYTHING

        self.data.dirtied.connect(self.dataDirtiedSlot)

        # Configure ctrl-w to close the window
        QShortcut(QKeySequence(Qt.CTRL + Qt.Key_W), self, self.close)
コード例 #7
0
def create_flat_button(
    icon=None,
    icon_size=None,
    name='',
    text=200,
    background_color=[54, 51, 51],
    ui_color=68,
    border_color=180,
    push_col=120,
    checkable=True,
    w_max=None,
    w_min=None,
    h_max=None,
    h_min=None,
    policy=None,
    tip=None,
    flat=True,
    hover=True,
    destroy_flag=False,
    context=None,
):

    btn = QPushButton()
    btn.setText(name)
    btn.setCheckable(checkable)
    if icon:
        if isinstance(icon, QIcon):
            btn.setIcon(icon)
        else:
            btn.setIcon(QIcon(icon))
    btn.setFlat(flat)
    if flat:
        change_button_color(button=btn,
                            text_color=text,
                            bg_color=ui_color,
                            hi_color=background_color,
                            mode='button',
                            hover=hover,
                            destroy=destroy_flag,
                            ds_color=border_color)
        btn.toggled.connect(
            lambda: change_button_color(button=btn,
                                        text_color=text,
                                        bg_color=ui_color,
                                        hi_color=background_color,
                                        mode='button',
                                        toggle=True,
                                        hover=hover,
                                        destroy=destroy_flag,
                                        ds_color=border_color))
    else:
        change_button_color(button=btn,
                            text_color=text,
                            bg_color=background_color,
                            hi_color=push_col,
                            mode='button',
                            hover=hover,
                            destroy=destroy_flag,
                            ds_color=border_color)

    if w_max:
        btn.setMaximumWidth(w_max)
    if w_min:
        btn.setMinimumWidth(w_min)
    if h_max:
        btn.setMaximumHeight(h_max)
    if h_min:
        btn.setMinimumHeight(h_min)
    if icon_size:
        btn.setIconSize(QSize(*icon_size))
    if policy:
        btn.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Expanding)
    if tip:
        btn.setToolTip(tip)
    if context:
        btn.setContextMenuPolicy(Qt.CustomContextMenu)
        btn.customContextMenuRequested.connect(context)

    return btn
コード例 #8
0
    def fill_tree(self, trigger_name=None, trigger_job=None):
        item_stack = [self.tree.invisibleRootItem()]

        self.tree.clear()

        jobs = self.session.seqcrow_job_manager.jobs

        for job in jobs:
            name = job.name
            parent = item_stack[0]
            item = QTreeWidgetItem(parent)
            item_stack.append(item)

            item.setData(self.NAME_COL, Qt.DisplayRole, job)
            item.setText(self.NAME_COL, name)

            if isinstance(job, LocalJob):
                if job.killed:
                    item.setText(self.STATUS_COL, "killed")

                    del_job_widget = QWidget()
                    del_job_layout = QGridLayout(del_job_widget)
                    del_job = QPushButton()
                    del_job.clicked.connect(
                        lambda *args, job=job: self.remove_job(job))
                    del_job.setIcon(
                        QIcon(del_job_widget.style().standardIcon(
                            QStyle.SP_DialogDiscardButton)))
                    del_job.setFlat(True)
                    del_job_layout.addWidget(del_job, 0, 0, 1, 1,
                                             Qt.AlignHCenter)
                    del_job_layout.setColumnStretch(0, 1)
                    del_job_layout.setContentsMargins(0, 0, 0, 0)
                    self.tree.setItemWidget(item, self.DEL_COL, del_job_widget)

                elif job.isRunning():
                    if job in self.session.seqcrow_job_manager.unknown_status_jobs:
                        unk_widget = QWidget()
                        unk_layout = QGridLayout(unk_widget)
                        unk = QPushButton()
                        unk.setIcon(
                            QIcon(unk_widget.style().standardIcon(
                                QStyle.SP_MessageBoxQuestion)))
                        unk.setFlat(True)
                        unk.clicked.connect(lambda *args, job=job: self.
                                            show_ask_if_running(job))
                        unk_layout.addWidget(unk, 0, 0, 1, 1, Qt.AlignHCenter)
                        unk_layout.setColumnStretch(0, 1)
                        unk_layout.setContentsMargins(0, 0, 0, 0)
                        self.tree.setItemWidget(item, self.STATUS_COL,
                                                unk_widget)

                    else:
                        item.setText(self.STATUS_COL, "running")

                        kill_widget = QWidget()
                        kill_layout = QGridLayout(kill_widget)
                        kill = QPushButton()
                        kill.setIcon(
                            QIcon(kill_widget.style().standardIcon(
                                QStyle.SP_DialogCancelButton)))
                        kill.setFlat(True)
                        kill.clicked.connect(lambda *args, job=job: job.kill())
                        kill.clicked.connect(
                            lambda *args, session=self.session: session.
                            seqcrow_job_manager.triggers.activate_trigger(
                                JOB_QUEUED, "resume"))
                        kill_layout.addWidget(kill, 0, 0, 1, 1, Qt.AlignLeft)
                        kill_layout.setColumnStretch(0, 0)
                        kill_layout.setContentsMargins(0, 0, 0, 0)
                        self.tree.setItemWidget(item, self.KILL_COL,
                                                kill_widget)

                elif job.isFinished():
                    if not job.error:
                        item.setText(self.STATUS_COL, "finished")
                    else:
                        error_widget = QWidget()
                        error_layout = QGridLayout(error_widget)
                        error = QPushButton()
                        error.setIcon(
                            QIcon(error_widget.style().standardIcon(
                                QStyle.SP_MessageBoxWarning)))
                        error.setFlat(True)
                        error.setToolTip(
                            "job did not finish without errors or output file cannot be found"
                        )
                        error_layout.addWidget(error, 0, 0, 1, 1,
                                               Qt.AlignHCenter)
                        error_layout.setColumnStretch(0, 1)
                        error_layout.setContentsMargins(0, 0, 0, 0)
                        self.tree.setItemWidget(item, self.STATUS_COL,
                                                error_widget)

                    del_job_widget = QWidget()
                    del_job_layout = QGridLayout(del_job_widget)
                    del_job = QPushButton()
                    del_job.clicked.connect(
                        lambda *args, job=job: self.remove_job(job))
                    del_job.setIcon(
                        QIcon(del_job_widget.style().standardIcon(
                            QStyle.SP_DialogDiscardButton)))
                    del_job.setFlat(True)
                    del_job_layout.addWidget(del_job, 0, 0, 1, 1,
                                             Qt.AlignHCenter)
                    del_job_layout.setColumnStretch(0, 1)
                    del_job_layout.setContentsMargins(0, 0, 0, 0)
                    self.tree.setItemWidget(item, self.DEL_COL, del_job_widget)

                else:
                    item.setText(self.STATUS_COL, "queued")

                    priority_widget = QWidget()
                    priority_layout = QGridLayout(priority_widget)
                    inc_priority = QPushButton()
                    inc_priority.setIcon(
                        QIcon(priority_widget.style().standardIcon(
                            QStyle.SP_ArrowUp)))
                    inc_priority.setFlat(True)
                    inc_priority.clicked.connect(
                        lambda *args, job=job: self.session.seqcrow_job_manager
                        .increase_priotity(job))
                    priority_layout.addWidget(inc_priority, 0, 0, 1, 1,
                                              Qt.AlignRight)
                    dec_priority = QPushButton()
                    dec_priority.setIcon(
                        QIcon(priority_widget.style().standardIcon(
                            QStyle.SP_ArrowDown)))
                    dec_priority.setFlat(True)
                    dec_priority.clicked.connect(
                        lambda *args, job=job: self.session.seqcrow_job_manager
                        .decrease_priotity(job))
                    priority_layout.addWidget(dec_priority, 0, 1, 1, 1,
                                              Qt.AlignLeft)
                    priority_layout.setColumnStretch(0, 1)
                    priority_layout.setColumnStretch(1, 1)
                    priority_layout.setContentsMargins(0, 0, 0, 0)
                    self.tree.setItemWidget(item, self.CHANGE_PRIORITY,
                                            priority_widget)

                    kill_widget = QWidget()
                    kill_layout = QGridLayout(kill_widget)
                    kill = QPushButton()
                    kill.setIcon(
                        QIcon(kill_widget.style().standardIcon(
                            QStyle.SP_DialogCancelButton)))
                    kill.setFlat(True)
                    kill.clicked.connect(lambda *args, job=job: job.kill())
                    kill.clicked.connect(
                        lambda *args, session=self.session: session.
                        seqcrow_job_manager.triggers.activate_trigger(
                            JOB_QUEUED, "resume"))
                    kill_layout.addWidget(kill, 0, 0, 1, 1, Qt.AlignLeft)
                    kill_layout.setColumnStretch(0, 0)
                    kill_layout.setContentsMargins(0, 0, 0, 0)
                    self.tree.setItemWidget(item, self.KILL_COL, kill_widget)

                item.setText(self.SERVER_COL, "local")

                if job.scratch_dir and os.path.exists(job.scratch_dir):
                    browse_widget = QWidget()
                    browse_layout = QGridLayout(browse_widget)
                    browse = QPushButton()
                    browse.clicked.connect(
                        lambda *args, job=job: self.browse_local(job))
                    browse.setIcon(
                        QIcon(browse_widget.style().standardIcon(
                            QStyle.SP_DirOpenIcon)))
                    browse.setFlat(True)
                    browse_layout.addWidget(browse, 0, 0, 1, 1, Qt.AlignLeft)
                    browse_layout.setColumnStretch(0, 1)
                    browse_layout.setContentsMargins(0, 0, 0, 0)
                    self.tree.setItemWidget(item, self.BROWSE_COL,
                                            browse_widget)

            self.tree.expandItem(item)

        self.tree.resizeColumnToContents(self.STATUS_COL)
        self.tree.resizeColumnToContents(self.SERVER_COL)
        self.tree.resizeColumnToContents(self.CHANGE_PRIORITY)
        self.tree.resizeColumnToContents(self.KILL_COL)
        self.tree.resizeColumnToContents(self.DEL_COL)
        self.tree.resizeColumnToContents(self.BROWSE_COL)
コード例 #9
0
ファイル: partedit.py プロジェクト: wdas/partio
    def __init__(self, parent=None):
        QMainWindow.__init__(self, parent)

        self.data = ParticleData()

        toolbar = self.addToolBar("Test")

        openButton = QPushButton("")
        openButton.setFlat(True)
        openButton.setIconSize( QSize(32, 32) )
        openButton.setIcon(QIcon("/jobs2/soft/icons/dlight/open.png"))
        openButton.setToolTip( "Open File" )
        toolbar.addWidget(openButton)
        openButton.clicked.connect(self.openSlot)
        QShortcut( QKeySequence(Qt.CTRL + Qt.Key_O), self, self.openSlot )

        saveButton = QPushButton("")
        saveButton.setFlat(True)
        saveButton.setIconSize( QSize(32, 32) )
        saveButton.setIcon(QIcon("/jobs2/soft/icons/dlight/file_save.png"))
        saveButton.setToolTip( "Save File" )
        toolbar.addWidget(saveButton)
        saveButton.clicked.connect(self.saveSlot)
        QShortcut( QKeySequence(Qt.CTRL + Qt.Key_S), self, self.saveSlot )

        saveDeltaButton = QPushButton("")
        saveDeltaButton.setFlat(True)
        saveDeltaButton.setIconSize( QSize(32, 32) )
        saveDeltaButton.setIcon(QIcon("/jobs2/soft/icons/dlight/file_save_as.png"))
        saveDeltaButton.setToolTip( "Save File As Delta" )
        toolbar.addWidget(saveDeltaButton)
        saveDeltaButton.clicked.connect(self.saveDeltaSlot)
        QShortcut( QKeySequence(Qt.CTRL + Qt.SHIFT + Qt.Key_S), self, self.saveDeltaSlot )

        addParticleButton = QPushButton("Particle")
        addParticleButton.setFlat(True)
        addParticleButton.setIconSize( QSize(32, 32) )
        addParticleButton.setIcon(QIcon("/jobs2/soft/icons/shared/plus.png"))
        addParticleButton.setToolTip( "Add Particle" )
        toolbar.addWidget(addParticleButton)
        addParticleButton.clicked.connect(self.addParticleSlot)

        addAttributeButton = QPushButton("Attribute")
        addAttributeButton.setFlat(True)
        addAttributeButton.setIconSize( QSize(32, 32) )
        addAttributeButton.setIcon(QIcon("/jobs2/soft/icons/shared/plus.png"))
        addAttributeButton.setToolTip( "Add Attribute" )
        toolbar.addWidget(addAttributeButton)
        addAttributeButton.clicked.connect(self.addAttributeSlot)

        splitter = QSplitter(self)
        self.setCentralWidget(splitter)

        particleTable = ParticleTableWidget(self.data, self)
        splitter.addWidget(particleTable)

        right = QWidget(self)
        splitter.addWidget(right)
        vbox = QVBoxLayout(right)
        right.setLayout(vbox)

        fixedAttrWidget = FixedAttributesWidget(self.data, self)
        vbox.addWidget(fixedAttrWidget)

        indexedStrings = IndexedStringsWidget(self.data, self)
        vbox.addWidget(indexedStrings)

        vbox.addStretch()

        # TODD: SCROLLABLE AREAS FOR EVERYTHING

        self.data.dirtied.connect(self.dataDirtiedSlot)


        # Configure ctrl-w to close the window
        QShortcut( QKeySequence(Qt.CTRL + Qt.Key_W), self, self.close )