コード例 #1
0
    def initUI(self):

        searchEdit = QLineEdit()
        grid = QGridLayout()
        grid.setSpacing(10)

        grid.addWidget(searchEdit, 1, 0)

        self.list = QListView()
        # Create an empty model for the list's data
        model = QStandardItemModel(self.list)

        for gameName, gameId in self.Games.items():
            game = QStandardItem(gameName)
            game.setEditable(False)
            model.appendRow(game)

        self.list.doubleClicked.connect(self.OnDoubleClick) # Launch Game
        # Apply the model to the list view
        self.list.setModel(model)
        self.list.setCurrentIndex(self.list.model().index(0, 0)) # Show the window and run the app

        grid.addWidget(self.list, 2, 0)

        self.setLayout(grid)

        self.setGeometry(300, 300, 350, 300)
        self.setWindowTitle('pySteamLauncher')
        self.setWindowIcon(QIcon('logo.png'))
        self.show()
コード例 #2
0
ファイル: filereader_panel.py プロジェクト: QChASM/SEQCROW
    def _build_ui(self):
        layout = QGridLayout()

        layout.setContentsMargins(0,0,0,0)
        layout.setSpacing(0)

        #TODO: make buttons disabled/enabled if items are selected that don't have the info
        self.tree = QTreeWidget()
        self.tree.setSelectionMode(QTreeWidget.ExtendedSelection)
        self.tree.setHeaderLabels(["Name", "ID", "movie", "energy", "frequencies"])
        self.tree.setUniformRowHeights(True)
        
        self.tree.setColumnWidth(self.NAME_COL, 200)
        layout.addWidget(self.tree, 0, 0, 3, 1)

        restore_button = QPushButton("restore")
        restore_button.clicked.connect(self.restore_selected)
        layout.addWidget(restore_button, 0, 1)
        
        nrg_plot_button = QPushButton("energy plot")
        nrg_plot_button.clicked.connect(self.open_nrg_plot)
        layout.addWidget(nrg_plot_button, 1, 1)
        
        coordset_slider_button = QPushButton("movie slider")
        coordset_slider_button.clicked.connect(self.open_movie_slider)
        layout.addWidget(coordset_slider_button, 2, 1)

        self.tool_window.ui_area.setLayout(layout)

        self.tool_window.manage(placement="side")
コード例 #3
0
ファイル: InputWidgets.py プロジェクト: pedroCabrera/PyFlow
class InputWidgetSingle(InputWidgetRaw):
    """
    This type of widget is used for a simple widgets like buttons, checkboxes etc.
    It consists of horizontal layout widget itself and reset button.
    """
    def __init__(self,
                 parent=None,
                 dataSetCallback=None,
                 defaultValue=None,
                 userStructClass=None,
                 **kwds):
        super(InputWidgetSingle,
              self).__init__(parent=parent,
                             dataSetCallback=dataSetCallback,
                             defaultValue=defaultValue,
                             userStructClass=userStructClass,
                             **kwds)
        # from widget
        self.bWidgetSet = False
        self.gridLayout = QGridLayout(self)
        self.gridLayout.setSpacing(1)
        self.gridLayout.setContentsMargins(0, 0, 0, 0)
        self.gridLayout.setObjectName("gridLayout")
        self.horizontalLayout = QHBoxLayout()
        self.horizontalLayout.setObjectName("horizontalLayout")

        spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding,
                                 QSizePolicy.Minimum)
        self.horizontalLayout.addItem(spacerItem)
        self.pbReset = QPushButton(self)
        self.pbReset.setMaximumSize(QtCore.QSize(25, 25))
        self.pbReset.setText("")
        self.pbReset.setObjectName("pbReset")
        self.pbReset.setIcon(QtGui.QIcon(":/icons/resources/reset.png"))
        self.horizontalLayout.addWidget(self.pbReset)
        self.pbReset.clicked.connect(self.onResetValue)

        self.gridLayout.addLayout(self.horizontalLayout, 0, 0, 1, 1)
        self._index = 0

    def setWidget(self, widget):
        self.horizontalLayout.insertWidget(self._index, widget)
コード例 #4
0
class FileManagerViewer(QWidget):
    def __init__(self, *args, **kwargs):
        super(FileManagerViewer, self).__init__(*args, **kwargs)

        self._lyt_grid = QGridLayout()
        self._toolbar = ViewerToolbar()

        self._build_ui()
        self._build_connections()
        self._setup_ui()

    def view_assets(self, asset_records):
        self._clear_grid()

        if not asset_records:
            return

        asset_records.sort(key=attrgetter('name'))

        engine = get_engine()

        # Find tags
        _links = engine.select(
            Query('tag_to_asset', asset_id=[_.id for _ in asset_records]))
        links_by_asset = dict(fm_groupby(_links, attrgetter('asset_id')))
        _tags = engine.select(Query('tag', id=[_.tag_id for _ in _links
                                               ])) if _links else list()
        tags_by_id = {_.id: _ for _ in _tags}

        # Find paths
        _paths = engine.select(
            Query('path', asset_id=[_.id for _ in asset_records]))
        paths_by_asset = dict(fm_groupby(_paths, attrgetter('asset_id')))

        FileManagerThumbnail.cache_app_icons()

        widgets = list()
        for asset_record in asset_records:
            _links = links_by_asset.get(asset_record.id, list())
            tags = [tags_by_id.get(link.tag_id) for link in _links]

            paths = paths_by_asset.get(asset_record.id, list())

            thumb = FileManagerThumbnail(asset_record, tags, paths)
            thumb.deleted.connect(self._remove_thumb)

            widgets.append(thumb)

        self._layout_widgets(widgets)

    def _build_ui(self):
        self._lyt_grid.setContentsMargins(0, 0, 0, 0)
        self._lyt_grid.setSpacing(10)
        self._lyt_grid.setAlignment(Qt.AlignTop | Qt.AlignLeft)

        scroll_area = QScrollArea()
        scroll_area.setFrameStyle(0)
        scroll_area.setWidget(QWidget())
        scroll_area.widget().setLayout(self._lyt_grid)
        scroll_area.setWidgetResizable(True)

        lyt_main = QVBoxLayout()
        lyt_main.setContentsMargins(0, 0, 0, 0)
        lyt_main.setSpacing(0)
        lyt_main.addWidget(scroll_area)
        lyt_main.addWidget(self._toolbar)
        self.setLayout(lyt_main)

    def _build_connections(self):
        self._toolbar.thumb_size_changed.connect(self.update_layout)

    def _setup_ui(self):
        pass

    def _remove_thumb(self):
        thumb = self.sender()
        self._lyt_grid.removeWidget(thumb)
        thumb.deleteLater()
        self.update_layout()

    def update_layout(self):
        widgets = list()
        while self._lyt_grid.count():
            wdg = self._lyt_grid.itemAt(0).widget()
            widgets.append(wdg)
            self._lyt_grid.removeWidget(wdg)

        self._layout_widgets(widgets)

    def _layout_widgets(self, widgets):
        for wdg in widgets:
            wdg.update_thumb_size()
        w = self.width()
        items_per_row = int(w / ((settings.thumb_size + 16) *
                                 FileManagerThumbnail.REF_WIDTH / 100.0))
        r, c = 0, 0
        while widgets:
            n = widgets.pop(0)
            self._lyt_grid.addWidget(n, r, c)
            c += 1
            if c >= items_per_row:
                r += 1
                c = 0

    def _clear_grid(self):
        while self._lyt_grid.count():
            item = self._lyt_grid.itemAt(0)
            wdg = item.widget()
            self._lyt_grid.removeWidget(wdg)
            wdg.close()
            wdg.deleteLater()
コード例 #5
0
    def _build_ui(self):
        layout = QGridLayout()

        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(0)

        self.tree = QTreeWidget()
        self.tree.setSelectionMode(QTreeWidget.ExtendedSelection)
        self.tree.setHeaderLabels([
            "name", "status", "server", "prioritize", "kill", "delete",
            "browse"
        ])
        self.tree.setUniformRowHeights(True)

        self.tree.setColumnWidth(0, 150)
        layout.addWidget(self.tree, 0, 0, 6, 1, Qt.AlignTop)

        row = 0

        pause_button = QPushButton(
            "pause new jobs"
            if not self.session.seqcrow_job_manager.paused else "resume jobs")
        pause_button.setCheckable(True)
        pause_button.clicked.connect(lambda check: pause_button.setText(
            "pause new jobs" if not check else "resume jobs"))
        pause_button.setChecked(self.session.seqcrow_job_manager.paused)
        pause_button.clicked.connect(self.pause_queue)
        layout.addWidget(pause_button, row, 1, 1, 1, Qt.AlignTop)

        row += 1

        open_button = QPushButton("open structure")
        open_button.clicked.connect(self.open_jobs)
        layout.addWidget(open_button, row, 1, 1, 1, Qt.AlignTop)

        row += 1

        log_button = QPushButton("log")
        log_button.clicked.connect(self.open_log)
        layout.addWidget(log_button, row, 1, 1, 1, Qt.AlignTop)

        row += 1

        output_button = QPushButton("raw output")
        output_button.clicked.connect(self.open_output)
        layout.addWidget(output_button, row, 1, 1, 1, Qt.AlignTop)

        row += 1

        refresh_button = QToolButton()
        refresh_button.setSizePolicy(QSizePolicy.Fixed,
                                     QSizePolicy.MinimumExpanding)
        refresh_button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
        refresh_button.setIcon(
            QIcon(refresh_button.style().standardIcon(
                QStyle.SP_BrowserReload)))
        refresh_button.setText('check jobs')
        refresh_button.clicked.connect(
            lambda *args: self.session.seqcrow_job_manager.triggers.
            activate_trigger(JOB_QUEUED, "refresh"))
        layout.addWidget(refresh_button, row, 1, 1, 1, Qt.AlignTop)

        row += 1

        for i in range(0, row - 1):
            layout.setRowStretch(i, 0)

        layout.setRowStretch(row - 1, 1)
        layout.setColumnStretch(0, 1)
        layout.setColumnStretch(1, 0)

        self.tool_window.ui_area.setLayout(layout)

        self.tool_window.manage(None)
コード例 #6
0
class PenSetWidget(QWidget):

    penSizeTrigger = Signal(int)
    penColorTrigger = Signal(str)
    fontChangeTrigger = Signal(QFont)

    def __init__(self, parent=None):
        super(PenSetWidget, self).__init__(parent)

        self.paddingX = 5
        self.paddingY = 2
        self.iconWidth = self.iconHeight = 24
        self.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed)
        self.setWindowFlags(Qt.ToolTip)

        self.initWindows()

        self.prevSizeButton = self.penSize1
        self.penSize1.setChecked(True)
        self.presentColor.setStyleSheet(
            'QPushButton { background-color: %s; }' % PENCOLOR)

    def generateButtons(self, parent=None):
        """ Generate buttons due to colorDic """
        self.colorButtons = []
        for color in self.colorList:
            button = QPushButton(parent)
            button.setObjectName(color[0])
            button.setStyleSheet('QPushButton { background-color: %s; }' %
                                 color[1])
            button.setFixedSize(self.iconWidth / 2, self.iconHeight / 2)
            button.setCheckable(True)
            self.colorButtons.append(button)

    def initWindows(self):
        self.mainLayout = QHBoxLayout()
        self.setLayout(self.mainLayout)
        self.mainLayout.setSpacing(0)
        self.mainLayout.setContentsMargins(5, 2, 5, 2)

        self.initPenSizeButtons()
        self.initFontWidget()
        self.initPenColorButtons()

        self.separator = QFrame(self)
        self.separator.setFrameShape(QFrame.VLine)
        self.separator.setFrameShadow(QFrame.Sunken)

        self.mainLayout.addWidget(self.penSize)
        self.mainLayout.addWidget(self.changeFontButton)
        self.mainLayout.addWidget(self.separator)

        self.mainLayout.addWidget(self.colorSet)

    def initPenSizeButtons(self):
        self.penSize = QWidget(self)
        self.penSizeLayout = QHBoxLayout()
        self.penSize.setLayout(self.penSizeLayout)
        # adjust pen size
        self.penSize1 = QPushButton(self.penSize)
        self.penSize1.setIcon(QIcon(":/resource/icon/pensize1.png"))
        self.penSize1.setObjectName('1')
        self.penSize1.setFixedSize(self.iconWidth, self.iconHeight)
        self.penSize1.setCheckable(True)

        self.penSize2 = QPushButton(self.penSize)
        self.penSize2.setIcon(QIcon(":/resource/icon/pensize2.png"))
        self.penSize2.setObjectName('2')
        self.penSize2.setFixedSize(self.iconWidth, self.iconHeight)
        self.penSize2.setCheckable(True)

        self.penSize3 = QPushButton(self.penSize)
        self.penSize3.setIcon(QIcon(":/resource/icon/pensize3.png"))
        self.penSize3.setObjectName('3')
        self.penSize3.setFixedSize(self.iconWidth, self.iconHeight)
        self.penSize3.setCheckable(True)

        self.sizeButtonGroup = QButtonGroup(self.penSize)
        self.sizeButtonGroup.addButton(self.penSize1)
        self.sizeButtonGroup.addButton(self.penSize2)
        self.sizeButtonGroup.addButton(self.penSize3)
        self.sizeButtonGroup.buttonClicked.connect(self.sizeButtonToggled)

        self.penSizeLayout.addWidget(self.penSize1)
        self.penSizeLayout.addWidget(self.penSize2)
        self.penSizeLayout.addWidget(self.penSize3)

        self.penSizeLayout.setSpacing(5)
        self.penSizeLayout.setContentsMargins(0, 0, 0, 0)

    def initPenColorButtons(self):
        self.colorSet = QWidget(self)
        self.colorLayout = QHBoxLayout()
        self.colorLayout.setSpacing(5)
        self.colorLayout.setContentsMargins(5, 0, 5, 0)
        self.colorSet.setLayout(self.colorLayout)

        self.presentColor = QPushButton(self.colorSet)
        self.presentColor.setFixedSize(self.iconWidth, self.iconHeight)
        self.presentColor.setEnabled(False)

        # adjust pen color

        self.colorPick = QWidget(self.colorSet)
        self.colorGrid = QGridLayout()
        self.colorGrid.setSpacing(0)
        self.colorGrid.setContentsMargins(5, 0, 5, 0)
        self.colorPick.setLayout(self.colorGrid)

        self.colorList = [('white', '#ffffff'), ('red', '#ff0000'),
                          ('green', '#00ff00'), ('blue', '#0000ff'),
                          ('cyan', '#00ffff'), ('magenta', '#ff00ff'),
                          ('yellow', '#ffff00'), ('gray', '#a0a0a4'),
                          ('black', '#000000'), ('darkRed', '#800000'),
                          ('darkGreen', '#008000'), ('darkBlue', '#000080'),
                          ('darkCyan', '#008080'), ('darkMagenta', '#800080'),
                          ('darkYellow', '#808000'), ('darkGray', '#808080')]

        self.generateButtons()

        self.colorButtonGroup = QButtonGroup(self)
        for button in self.colorButtons:
            self.colorButtonGroup.addButton(button)
        self.colorButtonGroup.buttonClicked.connect(self.colorButtonToggled)

        # set the layout
        tmp = 0
        for x in range(0, 2):
            for y in range(0, int(len(self.colorList) / 2)):
                self.colorGrid.addWidget(self.colorButtons[tmp], x, y)
                tmp += 1

        self.colorGrid.setSpacing(0)
        self.colorGrid.setContentsMargins(0, 0, 0, 0)

        self.colorLayout.addWidget(self.presentColor)
        self.colorLayout.addWidget(self.colorPick)

    def initFontWidget(self):
        self.fontDialog = QFontDialog()
        self.changeFontButton = QPushButton(self)
        self.fontDialog.setCurrentFont(QFont('Sans serif'))
        self.changeFontButton.setText('{0} {1}'.format(
            self.fontDialog.currentFont().family(),
            self.fontDialog.currentFont().pointSize()))
        self.changeFontButton.clicked.connect(self.fontButtonClicked)

    def showFontWidget(self):
        self.changeFontButton.show()
        self.penSize1.hide()
        self.penSize2.hide()
        self.penSize3.hide()

    def showPenWidget(self):
        self.changeFontButton.hide()
        self.penSize1.show()
        self.penSize2.show()
        self.penSize3.show()

    # slots
    def colorButtonToggled(self, button):
        self.presentColor.setStyleSheet(
            'QPushButton { background-color: %s; }' % button.objectName())
        self.penColorTrigger.emit(button.objectName())

    def sizeButtonToggled(self, button):
        self.penSizeTrigger.emit(int(button.objectName()) * 2)

    def fontButtonClicked(self):
        ok = True
        font = QFontDialog.getFont(self)
        if font[1]:
            self.changeFontButton.setText('{0} {1}'.format(
                font[0].family(), font[0].pointSize()))
            self.fontChangeTrigger.emit(font[0])