예제 #1
0
    def __init__(self, *args):
        super(StatusWidget, self).__init__(*args)

        self._status = None
        self._blocking = False
        self._timer = QTimer(self)

        self.setObjectName('StatusWidget')
        self.setFrameShape(QFrame.NoFrame)
        self.setFixedHeight(19)
        self.setMinimumWidth(5)

        self._label = label.BaseLabel('', parent=self)
        self._label.setStyleSheet('background-color: transparent;')
        self._label.setCursor(Qt.IBeamCursor)
        self._label.setTextInteractionFlags(Qt.TextSelectableByMouse)
        self._label.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)

        self.label_image = label.BaseLabel(parent=self)
        self.label_image.setMaximumSize(QSize(17, 17))
        self.label_image.hide()

        self.main_layout = QHBoxLayout(self)
        self.main_layout.setContentsMargins(1, 0, 0, 0)

        self.main_layout.addWidget(self.label_image)
        self.main_layout.addWidget(self._label)

        self.setLayout(self.main_layout)

        self._timer.timeout.connect(self._reset)

        # Force set to initialize default status Qt property
        self.status = ''
예제 #2
0
파일: partedit.py 프로젝트: wdas/partio
    def __init__(self, value, data, attr, particleNum, numColumns, parent=None):
        QWidget.__init__(self, parent)
        self.value = value
        self.data = data
        self.attr = attr
        self.particleNum = particleNum
        self.setFrameShape(QFrame.NoFrame)

        self.name = 'AttrWidget{}'.format(AttrWidget.widgetNumber)
        self.setObjectName(self.name)
        AttrWidget.widgetNumber += 1
        self.withBorderStyle = '#%s {border: 1px solid dodgerblue;}' % self.name
        self.noBorderStyle = '#%s {border: 0px;}' % self.name
        self.setStyleSheet(self.noBorderStyle)

        layout = QVBoxLayout()
        layout.setContentsMargins(0,0,0,0)
        self.setLayout(layout)

        idx = 0
        self.items = []
        self.textValues = []
        numRows = int(math.ceil(len(value) / float(numColumns)))
        for _ in range(numRows):
            row = QHBoxLayout()
            layout.addLayout(row)
            for _ in range(numColumns):
                item = NumericalEdit(value[idx])
                self.textValues.append(str(value[idx]))
                item.editingFinished.connect(self.applyEdit)
                row.addWidget(item, Qt.AlignHCenter|Qt.AlignTop)
                self.items.append(item)
                idx += 1
                if idx == len(self.value):
                    break
예제 #3
0
    def _build_ui(self):
        fields = self._entity.fields()
        fields = [
            x for x in fields if x.name not in ('id', 'timestamp', 'username')
        ]

        lyt_buttons = QHBoxLayout()
        lyt_buttons.addWidget(self._btn_create)
        lyt_buttons.addWidget(self._btn_cancel)

        r = 0
        lyt_grid = QGridLayout()
        for field in fields:
            editor = QLineEdit()
            if field.type == int:
                editor = QSpinBox()
                editor.setRange(-1000000, 1000000)
            self._wdg_map[field] = editor
            lyt_grid.addWidget(QLabel(field.name), r, 0)
            lyt_grid.addWidget(editor, r, 1)
            r += 1

        lyt_main = QVBoxLayout()
        lyt_main.addLayout(lyt_grid)
        lyt_main.addLayout(lyt_buttons)

        self.setLayout(lyt_main)
예제 #4
0
    def __init__(self, rawVariable, variablesWidget, parent=None):
        super(UIVariable, self).__init__(parent)
        self._rawVariable = rawVariable
        self.variablesWidget = variablesWidget
        # ui
        self.horizontalLayout = QHBoxLayout(self)
        self.horizontalLayout.setSpacing(1)
        self.horizontalLayout.setContentsMargins(1, 1, 1, 1)
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.widget = TypeWidget(findPinClassByType(self._rawVariable.dataType).color(), self)
        self.widget.setObjectName("widget")
        self.horizontalLayout.addWidget(self.widget)
        self.labelName = QLabel(self)
        self.labelName.setStyleSheet("background:transparent")
        self.labelName.setObjectName("labelName")
        self.horizontalLayout.addWidget(self.labelName)
        spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
        self.horizontalLayout.addItem(spacerItem)
        # find refs
        self.pbFindRefs = QPushButton("")
        self.pbFindRefs.setIcon(QtGui.QIcon(":/searching-magnifying-glass.png"))
        self.pbFindRefs.setObjectName("pbFindRefs")
        self.horizontalLayout.addWidget(self.pbFindRefs)
        self.pbFindRefs.clicked.connect(self.onFindRefsClicked)
        #  kill variable
        self.pbKill = QPushButton("")
        self.pbKill.setIcon(QtGui.QIcon(":/delete_icon.png"))
        self.pbKill.setObjectName("pbKill")
        self.horizontalLayout.addWidget(self.pbKill)
        self.pbKill.clicked.connect(self.onKillClicked)

        QtCore.QMetaObject.connectSlotsByName(self)
        self.setName(self._rawVariable.name)
        self._rawVariable.setWrapper(self)
예제 #5
0
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,
                 **kwds):
        super(InputWidgetSingle,
              self).__init__(parent=parent,
                             dataSetCallback=dataSetCallback,
                             defaultValue=defaultValue,
                             **kwds)
        self.horizontalLayout = QHBoxLayout(self)
        self.horizontalLayout.setObjectName("horizontalLayout")
        spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding,
                                 QSizePolicy.Minimum)
        self._index = 0
        self._widget = None
        self.senderPin = None

    def getWidget(self):
        return InputWidgetRaw.getWidget(self)

    def setWidget(self, widget):
        InputWidgetRaw.setWidget(self, widget)
        self.horizontalLayout.insertWidget(self._index, self.getWidget())
예제 #6
0
    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
예제 #7
0
    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)
예제 #8
0
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        self.populateScene()

        self.h1Splitter = QSplitter()
        self.h2Splitter = QSplitter()

        vSplitter = QSplitter()
        vSplitter.setOrientation(Qt.Vertical)
        vSplitter.addWidget(self.h1Splitter)
        vSplitter.addWidget(self.h2Splitter)

        view = View("Top left view")
        view.view().setScene(self.scene)
        self.h1Splitter.addWidget(view)

        view = View("Top right view")
        view.view().setScene(self.scene)
        self.h1Splitter.addWidget(view)

        view = View("Bottom left view")
        view.view().setScene(self.scene)
        self.h2Splitter.addWidget(view)

        view = View("Bottom right view")
        view.view().setScene(self.scene)
        self.h2Splitter.addWidget(view)

        layout = QHBoxLayout()
        layout.addWidget(vSplitter)
        self.setLayout(layout)

        self.setWindowTitle("Chip Demo")
예제 #9
0
    def initWindow(self, flags):
        self.hlayout = QHBoxLayout()
        self.hlayout.setSpacing(2)
        self.hlayout.setContentsMargins(10, 2, 10, 2)
        self.setLayout(self.hlayout)

        self.initDrawButtons(flags)
        self.initOtherButtons(flags)
 def __init__(self, parent=None, dataSetCallback=None, defaultValue=None, **kwds):
     super(InputWidgetSingle, self).__init__(parent=parent, dataSetCallback=dataSetCallback,
                                             defaultValue=defaultValue, **kwds)
     self.horizontalLayout = QHBoxLayout(self)
     self.horizontalLayout.setObjectName("horizontalLayout")
     spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
     self._index = 0
     self._widget = None
     self.senderPin = None
예제 #11
0
    def _build_ui(self):
        self._tree.setRootIsDecorated(False)
        self._tree.setSelectionMode(QTreeWidget.ExtendedSelection)

        lyt_main = QVBoxLayout()
        if self._allow_create:
            lyt_top = QHBoxLayout()
            lyt_top.setContentsMargins(0, 0, 0, 0)
            lyt_top.setSpacing(0)
            lyt_top.addWidget(self._btn_add)
            lyt_top.addStretch()
            lyt_main.addLayout(lyt_top)
        lyt_main.addWidget(self._tree)
        self.setLayout(lyt_main)
예제 #12
0
class TextInput(QWidget):
    # used when input text

    inputChanged = Signal()
    okPressed = Signal()
    cancelPressed = Signal()

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

        self.setWindowFlags(Qt.Dialog | Qt.FramelessWindowHint)

        self.mainLayout = QVBoxLayout()
        self.textArea = QTextEdit(self)

        self.buttonArea = QWidget(self)
        self.buttonLayout = QHBoxLayout()
        self.cancelButton = QPushButton('Cancel', self)
        self.okButton = QPushButton('Ok', self)
        self.buttonLayout.addWidget(self.cancelButton)
        self.buttonLayout.addWidget(self.okButton)
        self.buttonArea.setLayout(self.buttonLayout)

        self.mainLayout.addWidget(self.textArea)
        self.mainLayout.addWidget(self.buttonArea)
        self.setLayout(self.mainLayout)

        self.textArea.textChanged.connect(self.textChanged_)
        self.okButton.clicked.connect(self.okButtonClicked)
        self.cancelButton.clicked.connect(self.cancelPressed)

    def getText(self):
        return self.textArea.toPlainText()

    def getFocus(self):
        self.setFocus()
        self.textArea.setFocus()

    def clearText(self):
        self.textArea.clear()

    # slots
    def textChanged_(self):
        self.inputChanged.emit()

    def cancelButtonClicked(self):
        self.cancelPressed.emit()

    def okButtonClicked(self):
        self.okPressed.emit()
예제 #13
0
    def initUI(self):
        self.setFixedSize(400, 400)
        self.setWindowTitle('Colours')
        self.btnPaint = QPushButton("Paint", self)
        self.btnMove = QPushButton("Move x+1 y+1", self)
        self.rect = QRect()

        self.btnPaint.clicked.connect(self.onPaint)
        self.btnMove.clicked.connect(self.onMove)

        self.hlayout = QHBoxLayout(self)
        self.hlayout.addWidget(self.btnPaint)
        self.hlayout.addWidget(self.btnMove)
        self.hlayout.addStretch(1)
        self.show()
예제 #14
0
파일: tool.py 프로젝트: dials/cctbx
    def _build_ui(self):
        # Put our widgets in the tool window

        # We will use an editable single-line text input field (QLineEdit)
        # with a descriptive text label to the left of it (QLabel).  To
        # arrange them horizontally side by side we use QHBoxLayout
        from Qt.QtWidgets import QHBoxLayout
        from . import HKLviewer

        hbox = QHBoxLayout()
        self.Guiobj = HKLviewer.run(isembedded=True, chimeraxsession=self.session)
        hbox.addWidget(self.Guiobj.window)
        self.tool_window.ui_area.setLayout(hbox)
        # Show the window on the user-preferred side of the ChimeraX
        # main window
        self.tool_window.manage('side')
예제 #15
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)
예제 #16
0
    def __init__(self, dock_widget, renamable=False):
        super(DockTitleBar, self).__init__(dock_widget)

        self._renamable = renamable

        main_layout = QHBoxLayout()
        main_layout.setContentsMargins(0, 0, 0, 1)
        self.setLayout(main_layout)

        self._buttons_box = QGroupBox('')
        self._buttons_box.setObjectName('Docked')
        self._buttons_layout = QHBoxLayout()
        self._buttons_layout.setSpacing(1)
        self._buttons_layout.setMargin(2)
        self._buttons_box.setLayout(self._buttons_layout)
        main_layout.addWidget(self._buttons_box)

        self._title_label = QLabel(self)
        self._title_label.setStyleSheet('background: transparent')
        self._title_edit = QLineEdit(self)
        self._title_edit.setVisible(False)

        self._button_size = QSize(14, 14)

        self._dock_btn = QToolButton(self)
        self._dock_btn.setIcon(resources.icon('restore_window', theme='color'))
        self._dock_btn.setMaximumSize(self._button_size)
        self._dock_btn.setAutoRaise(True)
        self._close_btn = QToolButton(self)
        self._close_btn.setIcon(resources.icon('close_window', theme='color'))
        self._close_btn.setMaximumSize(self._button_size)
        self._close_btn.setAutoRaise(True)

        self._buttons_layout.addSpacing(2)
        self._buttons_layout.addWidget(self._title_label)
        self._buttons_layout.addWidget(self._title_edit)
        self._buttons_layout.addStretch()
        self._buttons_layout.addSpacing(5)
        self._buttons_layout.addWidget(self._dock_btn)
        self._buttons_layout.addWidget(self._close_btn)

        self._buttons_box.mouseDoubleClickEvent = self.mouseDoubleClickEvent
        self._buttons_box.mousePressEvent = self.mousePressEvent
        self._buttons_box.mouseMoveEvent = self.mouseMoveEvent
        self._buttons_box.mouseReleaseEvent = self.mouseReleaseEvent

        dock_widget.featuresChanged.connect(self._on_dock_features_changed)
        self._title_edit.editingFinished.connect(self._on_finish_edit)
        self._dock_btn.clicked.connect(self._on_dock_btn_clicked)
        self._close_btn.clicked.connect(self._on_close_btn_clicked)

        self._on_dock_features_changed(dock_widget.features())
        self.set_title(dock_widget.windowTitle())
        dock_widget.installEventFilter(self)
        dock_widget.topLevelChanged.connect(self._on_change_floating_style)
예제 #17
0
    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)
예제 #18
0
    def __init__(self, parent: QWidget = None):
        super().__init__(parent)

        self.setWindowFlags(self.windowFlags()
                            & ~Qt.WindowContextHelpButtonHint)

        self.server = QLocalServer(self)

        if not self.server.listen("fortune"):
            QMessageBox.critical(
                self,
                self.tr("Local Fortune Server"),
                self.tr("Unable to start the server: %s." %
                        (self.server.errorString())),
            )
            QTimer.singleShot(0, self.close)
            return

        statusLabel = QLabel()
        statusLabel.setWordWrap(True)
        statusLabel.setText(
            self.
            tr("The server is running.\nRun the Local Fortune Client example now."
               ))

        self.fortunes = (
            self.tr(
                "You've been leading a dog's life. Stay off the furniture."),
            self.tr("You've got to think about tomorrow."),
            self.tr("You will be surprised by a loud noise."),
            self.tr("You will feel hungry again in another hour."),
            self.tr("You might have mail."),
            self.tr("You cannot kill time without injuring eternity."),
            self.tr(
                "Computers are not intelligent. They only think they are."),
        )

        quitButton = QPushButton(self.tr("Quit"))
        quitButton.setAutoDefault(False)
        quitButton.clicked.connect(self.close)
        self.server.newConnection.connect(self.sendFortune)

        buttonLayout = QHBoxLayout()
        buttonLayout.addStretch(1)
        buttonLayout.addWidget(quitButton)
        buttonLayout.addStretch(1)

        mainLayout = QVBoxLayout(self)
        mainLayout.addWidget(statusLabel)
        mainLayout.addLayout(buttonLayout)

        self.setWindowTitle(QGuiApplication.applicationDisplayName())
예제 #19
0
    def __init__(self,
                 value,
                 data,
                 attr,
                 particleNum,
                 numColumns,
                 parent=None):
        QWidget.__init__(self, parent)
        self.value = value
        self.data = data
        self.attr = attr
        self.particleNum = particleNum
        self.setFrameShape(QFrame.NoFrame)

        self.name = 'AttrWidget{}'.format(AttrWidget.widgetNumber)
        self.setObjectName(self.name)
        AttrWidget.widgetNumber += 1
        self.withBorderStyle = '#%s {border: 1px solid dodgerblue;}' % self.name
        self.noBorderStyle = '#%s {border: 0px;}' % self.name
        self.setStyleSheet(self.noBorderStyle)

        layout = QVBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(layout)

        idx = 0
        self.items = []
        self.textValues = []
        numRows = int(math.ceil(len(value) / float(numColumns)))
        for _ in range(numRows):
            row = QHBoxLayout()
            layout.addLayout(row)
            for _ in range(numColumns):
                item = NumericalEdit(value[idx])
                self.textValues.append(str(value[idx]))
                item.editingFinished.connect(self.applyEdit)
                row.addWidget(item, Qt.AlignHCenter | Qt.AlignTop)
                self.items.append(item)
                idx += 1
                if idx == len(self.value):
                    break
예제 #20
0
def get_line_layout(title, parent, *widgets):
    """
    Returns a QHBoxLayout with all given widgets added to it
    :param parent: QWidget
    :param title: str
    :param widgets: list<QWidget>
    :return: QHBoxLayout
    """

    layout = QHBoxLayout()
    layout.setContentsMargins(1, 1, 1, 1)
    if title and title != '':
        label = QLabel(title, parent)
        layout.addWidget(label)
    for w in widgets:
        if isinstance(w, QWidget):
            layout.addWidget(w)
        elif isinstance(w, QLayout):
            layout.addLayout(w)

    return layout
예제 #21
0
    def __init__(self,
                 name,
                 value,
                 graph,
                 varsListWidget,
                 dataType=DataTypes.Bool,
                 uid=None):
        super(VariableBase, self).__init__()
        self._accessLevel = AccessLevel.public
        # ui
        self.horizontalLayout = QHBoxLayout(self)
        self.horizontalLayout.setSpacing(1)
        self.horizontalLayout.setContentsMargins(1, 1, 1, 1)
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.widget = TypeWidget(Colors.Bool, self)
        self.widget.setObjectName("widget")
        self.horizontalLayout.addWidget(self.widget)
        self.labelName = QLabel(self)
        self.labelName.setObjectName("labelName")
        self.horizontalLayout.addWidget(self.labelName, 1)
        spacerItem = QSpacerItem(1, 20, QSizePolicy.Expanding,
                                 QSizePolicy.Minimum)
        self.horizontalLayout.addItem(spacerItem)

        QtCore.QMetaObject.connectSlotsByName(self)
        # body
        self.varsListWidget = varsListWidget
        self.name = None
        self._value = value
        self.dataType = dataType
        self._uid = uid
        if self._uid is None:
            self._uid = uuid4()
        self.graph = graph
        self.setName(name)
        self.types = [
            v.name for v in list(DataTypes)
            if v not in [DataTypes.Reference, DataTypes.Exec, DataTypes.Enum]
        ]
        self.graph.vars[self.uid] = self
예제 #22
0
    def add_files(self, filenames):
        """add filenames (list(str)) to the table"""
        for f in filenames:
            row = self.table.rowCount()
            self.table.insertRow(row)

            file_item = QTableWidgetItem()
            file_item.setData(Qt.DisplayRole, f)
            self.table.setItem(row, 0, file_item)

            widget_that_lets_me_horizontally_align_an_icon = QWidget()
            widget_layout = QHBoxLayout(
                widget_that_lets_me_horizontally_align_an_icon)
            section_remove = QLabel()
            dim = int(1.5 *
                      section_remove.fontMetrics().boundingRect("Z").height())
            section_remove.setPixmap(
                QIcon(section_remove.style().standardIcon(
                    QStyle.SP_DialogDiscardButton)).pixmap(dim, dim))
            widget_layout.addWidget(section_remove, 0, Qt.AlignHCenter)
            widget_layout.setContentsMargins(0, 0, 0, 0)
            self.table.setCellWidget(
                row, 1, widget_that_lets_me_horizontally_align_an_icon)

        self.add_last_row()
예제 #23
0
    def __init__(self, tableName, parent=None):
        super().__init__(parent)
        self.model = QSqlTableModel(self)
        self.model.setTable(tableName)
        self.model.setEditStrategy(QSqlTableModel.OnManualSubmit)
        self.model.select()

        self.model.setHeaderData(0, Qt.Horizontal, self.tr("ID"))
        self.model.setHeaderData(1, Qt.Horizontal, self.tr("First name"))
        self.model.setHeaderData(2, Qt.Horizontal, self.tr("Last name"))

        view = QTableView()
        view.setModel(self.model)
        view.resizeColumnsToContents()

        self.submitButton = QPushButton(self.tr("Submit"))
        self.submitButton.setDefault(True)
        self.revertButton = QPushButton(self.tr("&Revert"))
        self.quitButton = QPushButton(self.tr("Quit"))

        self.buttonBox = QDialogButtonBox(Qt.Vertical)
        self.buttonBox.addButton(self.submitButton, QDialogButtonBox.ActionRole)
        self.buttonBox.addButton(self.revertButton, QDialogButtonBox.ActionRole)
        self.buttonBox.addButton(self.quitButton, QDialogButtonBox.RejectRole)

        self.submitButton.clicked.connect(self.submit)
        self.revertButton.clicked.connect(self.model.revertAll)
        self.quitButton.clicked.connect(self.close)

        mainLayout = QHBoxLayout()
        mainLayout.addWidget(view)
        mainLayout.addWidget(self.buttonBox)
        self.setLayout(mainLayout)

        self.setWindowTitle(self.tr("Cached Table"))
예제 #24
0
파일: row.py 프로젝트: z199416/MayaScript
    def __init__(self):
        super(Window, self).__init__()

        layout = QHBoxLayout()
        self.setLayout(layout)

        self.table_widget = TableWidgetDragRows()
        layout.addWidget(self.table_widget)

        # setup table widget
        self.table_widget.setColumnCount(2)
        self.table_widget.setHorizontalHeaderLabels(['Type', 'Name'])

        items = [('Red', 'Toyota'), ('Blue', 'RV'), ('Green', 'Beetle'),
                 ('Silver', 'Chevy'), ('Black', 'BMW')]
        self.table_widget.setRowCount(len(items))
        for i, (color, model) in enumerate(items):
            self.table_widget.setItem(i, 0, QTableWidgetItem(color))
            self.table_widget.setItem(i, 1, QTableWidgetItem(model))

        self.resize(400, 400)
        self.show()
예제 #25
0
    def __init__(self, parent=None):
        super(TextInput, self).__init__(parent)

        self.setWindowFlags(Qt.Dialog | Qt.FramelessWindowHint)

        self.mainLayout = QVBoxLayout()
        self.textArea = QTextEdit(self)

        self.buttonArea = QWidget(self)
        self.buttonLayout = QHBoxLayout()
        self.cancelButton = QPushButton('Cancel', self)
        self.okButton = QPushButton('Ok', self)
        self.buttonLayout.addWidget(self.cancelButton)
        self.buttonLayout.addWidget(self.okButton)
        self.buttonArea.setLayout(self.buttonLayout)

        self.mainLayout.addWidget(self.textArea)
        self.mainLayout.addWidget(self.buttonArea)
        self.setLayout(self.mainLayout)

        self.textArea.textChanged.connect(self.textChanged_)
        self.okButton.clicked.connect(self.okButtonClicked)
        self.cancelButton.clicked.connect(self.cancelPressed)
예제 #26
0
    def __init__(self):
        super(CenterWindow,self).__init__()
        self.setObjectName("CenterWindow")
      
        self.fileList = []       # 保存当前选择标签下的文件列表
        self.tag = ""  # 保存当前标签
        
        self.tableWidget_show = True  # tableWidget窗口是否显示
        self.row = 0  # 定位添加标签
        self.column = 0
       
        self.setupUI()

        # 设置tablewidget
        self.tableWidget = self.ui.findChild(QTableWidget, "tableWidget")
        
        self.tableWidget.setMaximumHeight(Data.getWindowHeight()/5)
        self.setTableWidget()
        self.tableWidget.setStyleSheet(Data.getQSS())
        self.tableWidget.setStyleSheet("background-color: #323232")

        self.searchWidget = self.ui.findChild(QWidget, "widget_2")
        self.search_engine_line_edit = MLineEdit().search_engine().large()
        dayu_theme.apply(self.search_engine_line_edit)
        self.searchWidget.setLayout(QHBoxLayout())
        self.searchWidget.layout().addWidget(self.search_engine_line_edit)

        self.slider = MSlider(Qt.Horizontal)
        self.slider.setMaximumWidth(Data.getWindowWidth()/4)
        self.slider.setValue(50)
        self.slider.setRange(1, 100)
        dayu_theme.apply(self.slider)
        self.searchWidget.layout().addWidget(self.slider)

       
        self.button_tag = MToolButton().svg('detail_line.svg').icon_only()
        self.button_tag.setEnabled(True)
        self.button_del = MToolButton().svg('trash_line.svg').icon_only()
        self.button_del.setCheckable(True)
        dayu_theme.apply(self.button_del)
        dayu_theme.apply(self.button_tag)

        self.searchWidget.layout().addWidget(self.button_tag)
        self.searchWidget.layout().addWidget(self.button_del)

        self.slider.valueChanged.connect(self.changeBtnSize)
        self.button_tag.clicked.connect(self.showTableWidget)
        self.button_del.clicked.connect(self.deleteTag)
        self.search_engine_line_edit.returnPressed.connect(self.on_searchBtn_click)
        self.setThread()
예제 #27
0
    def setupUI(self):

        # 设置为模态对话框
        self.setWindowModality(Qt.ApplicationModal)
        self.setStyleSheet("background-color:#262626")
        self.setMinimumSize(Data.getWindowWidth() / 3.5,
                            Data.getWindowHeight() / 2)

        self.ui = loadUi(file_path + "\\res\\UI\\TabWidegt.ui")

        self.ui.setParent(self)

        #设置布局
        self.setLayout(QHBoxLayout())
        self.layout().addWidget(self.ui)
        self.layout().setContentsMargins(0, 0, 0, 0)
예제 #28
0
    def addCircle(self):
       
       
        try:
            self.win = QWidget()
                
            self.win.setMinimumSize(self.child_widget.width()/1.05,self.child_widget.height()/1.1)

            self.loading_wrapper = MLoading.huge()

            self.win.setLayout(QHBoxLayout())
            self.win.layout().addWidget(self.loading_wrapper)

            self.widget.layout().addWidget(self.win)
        except:
            pass
예제 #29
0
파일: options.py 프로젝트: tristanic/isolde
 def _make_widget(self, **kw):
     nc = self.num_colors
     from chimerax.ui.widgets import MultiColorButton
     from Qt.QtWidgets import QWidget, QHBoxLayout, QLabel
     labels = kw.pop('labels', None)
     if labels is None:
         labels = [None] + ["  "] * (nc - 1)
     self.widget = QWidget()
     layout = QHBoxLayout()
     layout.setContentsMargins(0, 0, 0, 0)
     self._color_button = []
     initial_colors = kw.get('initial_colors', [default_color] * nc)
     for i in range(nc):
         label = labels[i]
         if label:
             layout.addWidget(QLabel(label))
         mcb = MultiColorButton(max_size=(16, 16), has_alpha_channel=True)
         self._color_button.append(mcb)
         mcb.color = initial_colors[i]
         mcb.color_changed.connect(lambda c, s=self: s.make_callback())
         layout.addWidget(mcb)
     self.widget.setLayout(layout)
예제 #30
0
    def __init__(self, parent=None):
        self._correctBackground = QColor(156, 206, 156, 255)
        self._correctForeground = QColor(Qt.white)
        self._inCorrectBackground = QColor(210, 156, 156, 255)
        self._inCorrectForeground = QColor(Qt.white)
        self._defaultLocation = ''
        QWidget.__init__(self, parent)

        self.uiFilenameTXT = LineEdit(self)
        self.uiPickFileBTN = QToolButton(self)
        self.uiPickFileBTN.setText('...')
        self.uiPickFileBTN.setToolTip(
            '<html><head/><body><p>Browse to a file path.</p><p>Ctrl + LMB: Explore to current path.</p></body></html>'
        )
        # Make this widget focusable and pass the widget focus to uiFilenameTXT
        self.setFocusProxy(self.uiFilenameTXT)
        self.setFocusPolicy(Qt.StrongFocus)
        layout = QHBoxLayout(self)
        layout.addWidget(self.uiFilenameTXT)
        layout.addWidget(self.uiPickFileBTN)
        layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(layout)

        self._caption = "Pick file..."
        self._filters = "All Files (*.*)"
        self._pickFolder = False
        self._openFile = False
        self._resolvePath = False
        #self._imageSequence = False
        self._resolved = False
        self._chosenPath = None
        #self._imageSequenceFormat = '{pre}[{firstNum}:{lastNum}]{post}'

        self.uiFilenameTXT.textChanged.connect(self.emitFilenameChanged)

        self.uiFilenameTXT.editingFinished.connect(self.emitFilenameEdited)
        self.uiPickFileBTN.clicked.connect(self.pickPath)
        self.resolvedStylesheet = resolvedStylesheetDefault

        self.resolve()
예제 #31
0
class Example(QWidget):
    def __init__(self):
        super(Example, self).__init__()
        self.initUI()

    def initUI(self):
        self.setFixedSize(400, 400)
        self.setWindowTitle('Colours')
        self.btnPaint = QPushButton("Paint", self)
        self.btnMove = QPushButton("Move x+1 y+1", self)
        self.rect = QRect()

        self.btnPaint.clicked.connect(self.onPaint)
        self.btnMove.clicked.connect(self.onMove)

        self.hlayout = QHBoxLayout(self)
        self.hlayout.addWidget(self.btnPaint)
        self.hlayout.addWidget(self.btnMove)
        self.hlayout.addStretch(1)
        self.show()

    def onPaint(self):
        if self.rect.isNull():
            self.rect = QRect(10, 15, 80, 45)
            self.update()

    def onMove(self):
        if not self.rect.isNull():
            self.rect.translate(QPoint(1, 1))
            self.update()

    def paintEvent(self, e):
        qp = QPainter(self)
        qp.setPen(QColor("#d4d4d4"))
        qp.setBrush(QColor(200, 0, 0))
        qp.drawRect(self.rect)
예제 #32
0
파일: qt.py 프로젝트: renemilk/pyMor
        def __init__(self, U, plot, length=1, title=None):
            super().__init__()

            layout = QVBoxLayout()

            if title:
                title = QLabel('<b>' + title + '</b>')
                title.setAlignment(Qt.AlignHCenter)
                layout.addWidget(title)
            layout.addWidget(plot)

            plot.set(U, 0)

            if length > 1:
                hlayout = QHBoxLayout()

                self.slider = QSlider(Qt.Horizontal)
                self.slider.setMinimum(0)
                self.slider.setMaximum(length - 1)
                self.slider.setTickPosition(QSlider.TicksBelow)
                hlayout.addWidget(self.slider)

                lcd = QLCDNumber(m.ceil(m.log10(length)))
                lcd.setDecMode()
                lcd.setSegmentStyle(QLCDNumber.Flat)
                hlayout.addWidget(lcd)

                layout.addLayout(hlayout)

                hlayout = QHBoxLayout()

                toolbar = QToolBar()
                self.a_play = QAction(self.style().standardIcon(QStyle.SP_MediaPlay), 'Play', self)
                self.a_play.setCheckable(True)
                self.a_rewind = QAction(self.style().standardIcon(QStyle.SP_MediaSeekBackward), 'Rewind', self)
                self.a_toend = QAction(self.style().standardIcon(QStyle.SP_MediaSeekForward), 'End', self)
                self.a_step_backward = QAction(self.style().standardIcon(QStyle.SP_MediaSkipBackward),
                                               'Step Back', self)
                self.a_step_forward = QAction(self.style().standardIcon(QStyle.SP_MediaSkipForward), 'Step', self)
                self.a_loop = QAction(self.style().standardIcon(QStyle.SP_BrowserReload), 'Loop', self)
                self.a_loop.setCheckable(True)
                toolbar.addAction(self.a_play)
                toolbar.addAction(self.a_rewind)
                toolbar.addAction(self.a_toend)
                toolbar.addAction(self.a_step_backward)
                toolbar.addAction(self.a_step_forward)
                toolbar.addAction(self.a_loop)
                if hasattr(self, 'save'):
                    self.a_save = QAction(self.style().standardIcon(QStyle.SP_DialogSaveButton), 'Save', self)
                    toolbar.addAction(self.a_save)
                    self.a_save.triggered.connect(self.save)
                hlayout.addWidget(toolbar)

                self.speed = QSlider(Qt.Horizontal)
                self.speed.setMinimum(0)
                self.speed.setMaximum(100)
                hlayout.addWidget(QLabel('Speed:'))
                hlayout.addWidget(self.speed)

                layout.addLayout(hlayout)

                self.timer = QTimer()
                self.timer.timeout.connect(self.update_solution)

                self.slider.valueChanged.connect(self.slider_changed)
                self.slider.valueChanged.connect(lcd.display)
                self.speed.valueChanged.connect(self.speed_changed)
                self.a_play.toggled.connect(self.toggle_play)
                self.a_rewind.triggered.connect(self.rewind)
                self.a_toend.triggered.connect(self.to_end)
                self.a_step_forward.triggered.connect(self.step_forward)
                self.a_step_backward.triggered.connect(self.step_backward)

                self.speed.setValue(50)

            elif hasattr(self, 'save'):
                hlayout = QHBoxLayout()
                toolbar = QToolBar()
                self.a_save = QAction(self.style().standardIcon(QStyle.SP_DialogSaveButton), 'Save', self)
                toolbar.addAction(self.a_save)
                hlayout.addWidget(toolbar)
                layout.addLayout(hlayout)
                self.a_save.triggered.connect(self.save)

            self.setLayout(layout)
            self.plot = plot
            self.U = U
            self.length = length
예제 #33
0
파일: qt.py 프로젝트: renemilk/pyMor
                def __init__(self):
                    super().__init__()
                    if separate_colorbars:
                        if rescale_colorbars:
                            self.vmins = tuple(np.min(u[0]) for u in U)
                            self.vmaxs = tuple(np.max(u[0]) for u in U)
                        else:
                            self.vmins = tuple(np.min(u) for u in U)
                            self.vmaxs = tuple(np.max(u) for u in U)
                    else:
                        if rescale_colorbars:
                            self.vmins = (min(np.min(u[0]) for u in U),) * len(U)
                            self.vmaxs = (max(np.max(u[0]) for u in U),) * len(U)
                        else:
                            self.vmins = (min(np.min(u) for u in U),) * len(U)
                            self.vmaxs = (max(np.max(u) for u in U),) * len(U)

                    layout = QHBoxLayout()
                    plot_layout = QGridLayout()
                    self.colorbarwidgets = [cbar_widget(self, vmin=vmin, vmax=vmax) if cbar_widget else None
                                            for vmin, vmax in zip(self.vmins, self.vmaxs)]
                    plots = [widget(self, grid, vmin=vmin, vmax=vmax, bounding_box=bounding_box, codim=codim)
                             for vmin, vmax in zip(self.vmins, self.vmaxs)]
                    if legend:
                        for i, plot, colorbar, l in zip(range(len(plots)), plots, self.colorbarwidgets, legend):
                            subplot_layout = QVBoxLayout()
                            caption = QLabel(l)
                            caption.setAlignment(Qt.AlignHCenter)
                            subplot_layout.addWidget(caption)
                            if not separate_colorbars or backend == 'matplotlib':
                                subplot_layout.addWidget(plot)
                            else:
                                hlayout = QHBoxLayout()
                                hlayout.addWidget(plot)
                                if colorbar:
                                    hlayout.addWidget(colorbar)
                                subplot_layout.addLayout(hlayout)
                            plot_layout.addLayout(subplot_layout, int(i/columns), (i % columns), 1, 1)
                    else:
                        for i, plot, colorbar in zip(range(len(plots)), plots, self.colorbarwidgets):
                            if not separate_colorbars or backend == 'matplotlib':
                                plot_layout.addWidget(plot, int(i/columns), (i % columns), 1, 1)
                            else:
                                hlayout = QHBoxLayout()
                                hlayout.addWidget(plot)
                                if colorbar:
                                    hlayout.addWidget(colorbar)
                                plot_layout.addLayout(hlayout, int(i/columns), (i % columns), 1, 1)
                    layout.addLayout(plot_layout)
                    if not separate_colorbars:
                        layout.addWidget(self.colorbarwidgets[0])
                        for w in self.colorbarwidgets[1:]:
                            w.setVisible(False)
                    self.setLayout(layout)
                    self.plots = plots
예제 #34
0
파일: partedit.py 프로젝트: wdas/partio
    def addAttributeSlot(self):
        """ Adds a new attribute (column) to the table """

        dialog = QDialog(self)
        dialog.setModal(True)
        dialog.setWindowTitle('Add Attribute')

        layout = QVBoxLayout()
        dialog.setLayout(layout)

        form = QFormLayout()
        nameBox = QLineEdit()
        typeCombo = QComboBox()
        for attrType in _attrTypes:
            typeName = partio.TypeName(attrType)
            typeCombo.addItem(typeName)
        typeCombo.setCurrentIndex(partio.FLOAT)
        countBox = QLineEdit()
        countBox.setValidator(QIntValidator())
        countBox.setText('1')
        fixedCheckbox = QCheckBox()
        valueBox = QLineEdit()
        valueBox.setText('0')
        form.addRow('Name:', nameBox)
        form.addRow('Type:', typeCombo)
        form.addRow('Count:', countBox)
        form.addRow('Fixed:', fixedCheckbox)
        form.addRow('Default Value:', valueBox)
        layout.addLayout(form)

        buttons = QHBoxLayout()
        layout.addLayout(buttons)

        add = QPushButton('Add')
        add.clicked.connect(dialog.accept)
        buttons.addWidget(add)

        cancel = QPushButton('Cancel')
        cancel.clicked.connect(dialog.reject)
        buttons.addWidget(cancel)

        if not dialog.exec_():
            return

        name = str(nameBox.text())
        if not name:
            print 'Please supply a name for the new attribute' # TODO: prompt
            return

        attrType = typeCombo.currentIndex()
        count = int(countBox.text())
        fixed = fixedCheckbox.isChecked()
        values = list(str(valueBox.text()).strip().split())
        for i in range(count):
            if i < len(values):
                value = values[i]
            else:
                value = values[-1]
            if attrType == partio.INT or attrType == partio.INDEXEDSTR:
                values[i] = int(value)
            elif attrType == partio.FLOAT or attrType == partio.VECTOR:
                values[i] = float(value) # pylint:disable=R0204
            else:
                values[i] = 0.0 # pylint:disable=R0204
        value = tuple(values)

        self.data.addAttribute(name, attrType, count, fixed, value)