Exemplo n.º 1
0
    def load(self):
        layout = self.layout()

        # Clear
        for btn in self._visButtons:
            layout.removeWidget(btn)
            btn.setVisible(False)
            #TODO sip delete?
        self._visButtons = []

        layers = self._guide.getLayersDepths()
        for i, (depth, layer) in enumerate(layers, start=1):
            btn = QPushButton("    " * depth + layer.name())
            btn.setStyleSheet("Text-align:left")
            btn.setMaximumHeight(20)
            layout.addWidget(btn, i, 0)
            self._visButtons.append(btn)

            for j, option in enumerate(OPTIONS, start=1):
                btn = QPushButton()
                btn.setFixedSize(30, 20)
                kwargs = {x: option == x for x in OPTIONS}
                visible = layer.isVisible(**kwargs)
                self.setButtonColor(btn, visible)

                btn.clicked.connect(
                    partial(self.toggleVisibility, btn, layer, option))

                layout.addWidget(btn, i, j)
                self._visButtons.append(btn)
Exemplo n.º 2
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)
Exemplo n.º 3
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
Exemplo n.º 4
0
    def __init__(self,
                 name='SaveFile',
                 title='Save File',
                 size=(200, 125),
                 fixed_size=False,
                 frame_less=True,
                 hide_title=False,
                 parent=None,
                 use_app_browser=False):

        parent = parent or dcc.get_main_window()

        super(BaseSaveFileDialog,
              self).__init__(name=name,
                             title=title,
                             size=size,
                             fixed_size=fixed_size,
                             frame_less=frame_less,
                             hide_title=hide_title,
                             use_app_browser=use_app_browser,
                             parent=parent)

        self._open_button.setText('Save')
        size = QSize(42, 24)
        self.new_directory_button = QPushButton('New')
        self.new_directory_button.setToolTip('Create new directory')
        self.new_directory_button.setMinimumSize(size)
        self.new_directory_button.setMaximumWidth(size)
        self.new_directory_button.clicked.connect(self.create_new_directory)
        self.grid.itemAtPosition(0, 1).addWidget(self.new_directory_button, 0,
                                                 5)
Exemplo n.º 5
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"))
Exemplo n.º 6
0
def failed_template_warning(residue):
    '''
    Warning dialog handling the case where a template is not recognised by
    OpenMM when attempting to start a simulation.
    '''
    from Qt.QtWidgets import QMessageBox, QPushButton
    msg = QMessageBox()
    msg.setIcon(QMessageBox.Warning)
    msgtext = 'Residue {} {} of chain {} (shown) does not match any template'\
        + ' in the molecular dynamics database. It may be missing atoms (have'\
        + ' you added hydrogens?) or be an unusual residue that has not been'\
        + ' parameterised. Choose what you wish to do with it from the options'\
        + ' below.'
    msg.setText(msgtext.format(residue.name, residue.number, residue.chain_id))

    addh = QPushButton('Add hydrogens and retry')
    msg.addButton(addh, QMessageBox.AcceptRole)
    exclude = QPushButton('Exclude residue from simulations and retry')
    msg.addButton(exclude, QMessageBox.RejectRole)
    abort = QPushButton('Abort')
    msg.addButton(abort, QMessageBox.NoRole)
    msg.exec_()
    btn = msg.clickedButton()
    # print("Button: {}".format(btn))
    if btn == addh:
        return "addh"
    if btn == exclude:
        return "exclude"
    return "abort"
Exemplo n.º 7
0
    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")
Exemplo n.º 8
0
	def addWidgets(self):
		uiRotationLAY = self.uiTrackedRotationGRP.layout()
		
		for i in xrange(2, self.count("Rail")+1):
			uiLabel = QLabel("Slider {}".format(i))
			
			uiMinRot = self._addQDoubleSpinBox(-180.0, 180.0, 15.0)
			uiMaxRot = self._addQDoubleSpinBox(-180.0, 180.0, 15.0)
			
			uiAxis = QComboBox()
			uiAxis.addItems(["X","Y","Z"])

			uiSelect = QPushButton("Select")
			uiSet = QPushButton("Set")
			
			uiRotationLAY.addWidget(uiLabel, i, 0)
			uiRotationLAY.addWidget(uiMinRot, i, 1)
			uiRotationLAY.addWidget(uiMaxRot, i, 2)
			uiRotationLAY.addWidget(uiAxis, i, 3)
			uiRotationLAY.addWidget(uiSelect, i, 4)
			uiRotationLAY.addWidget(uiSet, i, 5)
			
			self.__dict__["uiMinRot{}".format(i)] = uiMinRot
			self.__dict__["uiMaxRot{}".format(i)] = uiMaxRot
			self.__dict__["uiAxis{}".format(i)] = uiAxis
			self.__dict__["uiSelect{}".format(i)] = uiSelect
			self.__dict__["uiSet{}".format(i)] = uiSet
Exemplo n.º 9
0
    def create(self, delete_if_exists=True):
        """
        Creates a new shelf
        """

        if delete_if_exists:
            if gui.shelf_exists(shelf_name=self._name):
                gui.delete_shelf(shelf_name=self._name)
        else:
            assert not gui.shelf_exists(self._name), 'Shelf with name {} already exists!'.format(self._name)

        self._name = gui.create_shelf(name=self._name)

        # ========================================================================================================

        self._category_btn = QPushButton('')
        if self._category_icon:
            self._category_btn.setIcon(self._category_icon)
        self._category_btn.setIconSize(QSize(18, 18))
        self._category_menu = QMenu(self._category_btn)
        self._category_btn.setStyleSheet(
            'QPushButton::menu-indicator {image: url(myindicator.png);'
            'subcontrol-position: right center;subcontrol-origin: padding;left: -2px;}')
        self._category_btn.setMenu(self._category_menu)
        self._category_lbl = QLabel('MAIN')
        self._category_lbl.setAlignment(Qt.AlignCenter)
        font = self._category_lbl.font()
        font.setPointSize(6)
        self._category_lbl.setFont(font)
        menu_ptr = maya.OpenMayaUI.MQtUtil.findControl(self._name)
        menu_widget = qtutils.wrapinstance(menu_ptr, QWidget)
        menu_widget.layout().addWidget(self._category_btn)
        menu_widget.layout().addWidget(self._category_lbl)

        self.add_separator()
Exemplo n.º 10
0
    def ui(self):

        self.color_buttons = list()

        super(BaseColorDialog, self).ui()

        grid_layout = layouts.GridLayout()
        grid_layout.setAlignment(Qt.AlignTop)
        self.main_layout.addLayout(grid_layout)
        color_index = 0
        for i in range(0, 4):
            for j in range(0, 8):
                color_btn = QPushButton()
                color_btn.setMinimumHeight(35)
                color_btn.setMinimumWidth(35)
                self.color_buttons.append(color_btn)
                color_btn.setStyleSheet(
                    'background-color:rgb(%s,%s,%s);' %
                    (self.maya_colors[color_index][0] * 255,
                     self.maya_colors[color_index][1] * 255,
                     self.maya_colors[color_index][2] * 255))
                grid_layout.addWidget(color_btn, i, j)
                color_index += 1
        selected_color_layout = layouts.HorizontalLayout()
        self.main_layout.addLayout(selected_color_layout)
        self.color_slider = QSlider(Qt.Horizontal)
        self.color_slider.setMinimum(0)
        self.color_slider.setMaximum(31)
        self.color_slider.setValue(2)
        self.color_slider.setStyleSheet(
            "QSlider::groove:horizontal {border: 1px solid #999999;height: 25px; /* the groove expands "
            "to the size of the slider by default. by giving it a height, it has a fixed size */background: "
            "qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #B1B1B1, stop:1 #c4c4c4);margin: 2px 0;}"
            "QSlider::handle:horizontal {background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #b4b4b4,"
            " stop:1 #8f8f8f);border: 1px solid #5c5c5c;width: 10px;margin: -2px 0; /* handle is placed by "
            "default on the contents rect of the groove. Expand outside the groove */border-radius: 1px;}"
        )
        selected_color_layout.addWidget(self.color_slider)

        color_label_layout = layouts.HorizontalLayout(margins=(10, 10, 10, 10))
        self.main_layout.addLayout(color_label_layout)

        self.color_lbl = QLabel()
        self.color_lbl.setStyleSheet(
            "border: 1px solid black; background-color:rgb(0, 0, 0);")
        self.color_lbl.setMinimumWidth(45)
        self.color_lbl.setMaximumWidth(80)
        self.color_lbl.setMinimumHeight(80)
        self.color_lbl.setAlignment(Qt.AlignCenter)
        color_label_layout.addWidget(self.color_lbl)

        bottom_layout = layouts.HorizontalLayout()
        bottom_layout.setAlignment(Qt.AlignRight)
        self.main_layout.addLayout(bottom_layout)

        self.ok_btn = QPushButton('Ok')
        self.cancel_btn = QPushButton('Cancel')
        bottom_layout.addLayout(dividers.DividerLayout())
        bottom_layout.addWidget(self.ok_btn)
        bottom_layout.addWidget(self.cancel_btn)
Exemplo n.º 11
0
 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)
Exemplo n.º 12
0
    def ui(self):
        super(Badge, self).ui()

        self._badge_btn = QPushButton()
        self._badge_btn.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)

        if self._widget is not None:
            self.main_layout.addWidget(self._widget, 0, 0)
        self.main_layout.addWidget(self._badge_btn, 0, 0,
                                   Qt.AlignTop | Qt.AlignRight)
Exemplo n.º 13
0
 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)
Exemplo n.º 14
0
	def __init__(self):
		super(Window, self).__init__()

		flowLayout = FlowLayout()
		flowLayout.addWidget(QPushButton("Short"))
		flowLayout.addWidget(QPushButton("Longer"))
		flowLayout.addWidget(QPushButton("Different text"))
		flowLayout.addWidget(QPushButton("More text"))
		flowLayout.addWidget(QPushButton("Even longer button text"))
		self.setLayout(flowLayout)

		self.setWindowTitle("Flow Layout")
Exemplo n.º 15
0
class ExecInputWidget(InputWidgetSingle):
    """docstring for ExecInputWidget"""
    def __init__(self, parent=None, **kwds):
        super(ExecInputWidget, self).__init__(parent=parent, **kwds)
        self.pb = QPushButton('execute', self)
        self.setWidget(self.pb)
        self.pb.clicked.connect(self.dataSetCallback)
        self.pbReset.deleteLater()

    def setObjectName(self, name):
        super(ExecInputWidget, self).setObjectName(name)
        self.pb.setText(name.split(".")[-1])
Exemplo n.º 16
0
class TableEditor(QWidget):
    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"))

    def submit(self):
        self.model.database().transaction()
        if self.model.submitAll():
            self.model.database().commit()
        else:
            self.model.database().rollback()
            QMessageBox.warning(
                self,
                self.tr("Cached Table"),
                self.tr(
                    "The database reported an error: {}".format(
                        self.model.lastError().text()
                    )
                ),
            )
Exemplo n.º 17
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())
Exemplo n.º 18
0
    def __init__(self,
        auto_resize=False,
        single_row_select=True,
        context_menu_callback=None,
        last_column_stretch=True,
        has_counters=False,
        parent=None
    ):
        QFrame.__init__(self, parent)
        self._has_counters = has_counters

        self.model = None

        self.table_view = RowTableView(auto_resize, single_row_select, context_menu_callback, last_column_stretch)
        self.table_view.doubleClicked.connect(self._double_clicked)

        if has_counters:
            self.counters = Counters()
            self.counters.button_clicked.connect(self._counter_clicked)

        self.search_bar = QLineEdit()
        self.search_bar.setFixedHeight(SEARCHBAR_HEIGHT)
        self.search_bar.textChanged.connect(self.set_search_text)
        self.search_bar.setToolTip("Search bar")

        self.auto_size_button = QPushButton('<>')
        self.auto_size_button.setFixedSize(SEARCHBAR_HEIGHT, SEARCHBAR_HEIGHT)
        self.auto_size_button.clicked.connect(self._auto_size_clicked)
        self.auto_size_button.setToolTip("Auto size")

        self.status_label = QLabel(STATUS_LABEL_MESSAGE.format(0, 0))
        self.status_label.setFixedWidth(STATUS_LABEL_WIDTH)

        self.progress_bar = QProgressBar()
        self.progress_bar.setFormat('')

        layout = QGridLayout()

        layout.addWidget(self.search_bar, 0, 0, 1, 3)
        layout.addWidget(self.auto_size_button, 0, 3)
        if has_counters:
            layout.addWidget(self.counters, 1, 0, 1, 2)
            layout.addWidget(self.table_view, 1, 2, 1, 2)
        else:
            layout.addWidget(self.table_view, 1, 0, 1, 4)
        layout.addWidget(self.status_label, 2, 0)
        layout.addWidget(self.progress_bar, 2, 1, 1, 3)
        layout.setColumnStretch(2, 100)

        self.setLayout(layout)
Exemplo n.º 19
0
    def __init__(self, title='', parent=None):
        super(ExpandableGroup, self).__init__(title, parent)

        self.close_btn = QPushButton('-', self)
        self.close_btn.clicked.connect(self.toggle)

        self.setMouseTracking(True)

        self.setFont(QFont('Verdana', 10, QFont.Bold))
        self.setTitle('     ' + self.title())

        self.expanded = True

        self.hitbox = QRect(0, 0, self.width(), 18)
Exemplo n.º 20
0
    def _build_ui(self):
        """
        ui should have:
            * table with a list of available tests and show results after they are done
            * way to filter tests
            * button to run tests
        """
        layout = QFormLayout()

        # table to list test classes and the results
        self.table = QTableWidget()
        self.table.setColumnCount(2)
        self.table.setHorizontalHeaderLabels(["test", "result"])
        self.table.horizontalHeader().setSectionResizeMode(
            0,
            self.table.horizontalHeader().Interactive)
        self.table.setEditTriggers(QTableWidget.NoEditTriggers)
        self.table.horizontalHeader().setSectionResizeMode(
            1,
            self.table.horizontalHeader().Stretch)
        self.table.setSizePolicy(QSizePolicy.MinimumExpanding,
                                 QSizePolicy.MinimumExpanding)
        self.table.setSelectionBehavior(self.table.SelectRows)
        layout.addRow(self.table)

        self.filter = QLineEdit()
        self.filter.setPlaceholderText("filter test names")
        self.filter.setClearButtonEnabled(True)
        self.filter.textChanged.connect(self.apply_filter)
        layout.addRow(self.filter)

        self.profile = QCheckBox()
        self.profile.setToolTip("profile functions called during testing "
                                "using cProfile")
        layout.addRow("profile calls:", self.profile)

        self.run_button = QPushButton("run tests")
        self.run_button.clicked.connect(self.run_tests)
        self.run_button.setToolTip(
            "if no tests are selected on the table, run all tests\n" +
            "otherwise, run selected tests")
        layout.addRow(self.run_button)

        self.fill_table()
        self.table.resizeColumnToContents(0)

        self.tool_window.ui_area.setLayout(layout)

        self.tool_window.manage(None)
Exemplo n.º 21
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()
Exemplo n.º 22
0
    def __init__(self, entity, *args, **kwargs):
        super(RecordCreation, self).__init__(*args, **kwargs)

        self._entity = entity

        self.new_record = None

        self._wdg_map = dict()

        self._btn_cancel = QPushButton('CANCEL')
        self._btn_create = QPushButton('CREATE')

        self._build_ui()
        self._build_connections()
        self._setup_ui()
Exemplo n.º 23
0
    def __init__(self, parent: QWidget = None):
        super().__init__(parent)

        self._in = QDataStream()
        self.blockSize = 0

        self.currentFortune = ""

        self.hostLineEdit = QLineEdit("fortune")
        self.getFortuneButton = QPushButton(self.tr("Get Fortune"))
        self.statusLabel = QLabel(
            self.tr(
                "This examples requires that you run the Local Fortune Server example as well."
            )
        )
        self.socket = QLocalSocket()

        self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint)
        hostLabel = QLabel(self.tr("&Server name:"))
        hostLabel.setBuddy(self.hostLineEdit)

        self.statusLabel.setWordWrap(True)

        self.getFortuneButton.setDefault(True)
        quitButton = QPushButton(self.tr("Quit"))

        buttonBox = QDialogButtonBox()
        buttonBox.addButton(self.getFortuneButton, QDialogButtonBox.ActionRole)
        buttonBox.addButton(quitButton, QDialogButtonBox.RejectRole)

        self._in.setDevice(self.socket)
        self._in.setVersion(QDataStream.Qt_5_10)

        self.hostLineEdit.textChanged.connect(self.enableGetFortuneButton)

        self.getFortuneButton.clicked.connect(self.requestNewFortune)
        quitButton.clicked.connect(self.close)
        self.socket.readyRead.connect(self.readFortune)
        self.socket.errorOccurred.connect(self.displayError)

        mainLayout = QGridLayout(self)
        mainLayout.addWidget(hostLabel, 0, 0)
        mainLayout.addWidget(self.hostLineEdit, 0, 1)
        mainLayout.addWidget(self.statusLabel, 2, 0, 1, 2)
        mainLayout.addWidget(buttonBox, 3, 0, 1, 2)

        self.setWindowTitle(QGuiApplication.applicationDisplayName())
        self.hostLineEdit.setFocus()
Exemplo n.º 24
0
    def _build_ui(self):
        layout = QFormLayout()

        self.table = QTableWidget()
        self.table.setColumnCount(2)
        self.table.setHorizontalHeaderLabels(["file", "remove"])
        self.table.horizontalHeader().setStretchLastSection(False)
        self.table.horizontalHeader().setSectionResizeMode(
            0, QHeaderView.Stretch)
        self.table.horizontalHeader().setSectionResizeMode(
            1, QHeaderView.Fixed)
        self.table.cellClicked.connect(self.table_clicked)
        layout.addRow(self.table)

        self.linters = QComboBox()
        self.linters.addItems([
            "pyflakes",
            "flake8",
            "mypy",
            "pydocstyle",
            "pylint",
        ])
        ndx = self.linters.findText(self.settings.linter, Qt.MatchExactly)
        self.linters.setCurrentIndex(ndx)
        layout.addRow(self.linters)

        lint = QPushButton("run linter")
        lint.clicked.connect(self.run_linter)
        layout.addRow(lint)

        self.add_files(loads(self.settings.files))

        self.tool_window.ui_area.setLayout(layout)

        self.tool_window.manage(None)
Exemplo n.º 25
0
    def createPropertiesWidget(self, propertiesWidget):
        baseCategory = CollapsibleFormWidget(headName="Base")
        # name
        le_name = QLineEdit(self.getName())
        le_name.setReadOnly(True)
        # if self.isRenamable():
        le_name.setReadOnly(False)
        le_name.returnPressed.connect(lambda: self.setName(le_name.text()))
        baseCategory.addWidget("Name", le_name)

        # type
        leType = QLineEdit(self.__class__.__name__)
        leType.setReadOnly(True)
        baseCategory.addWidget("Type", leType)

        # pos
        le_pos = QLineEdit("{0} x {1}".format(self.pos().x(), self.pos().y()))
        baseCategory.addWidget("Pos", le_pos)
        propertiesWidget.addWidget(baseCategory)

        appearanceCategory = CollapsibleFormWidget(headName="Appearance")
        pb = QPushButton("...")
        pb.clicked.connect(lambda: self.onChangeColor(True))
        appearanceCategory.addWidget("Color", pb)
        propertiesWidget.addWidget(appearanceCategory)

        infoCategory = CollapsibleFormWidget(headName="Info")

        doc = QTextBrowser()
        doc.setOpenExternalLinks(True)
        doc.setHtml(self.description())
        infoCategory.addWidget("", doc)
        propertiesWidget.addWidget(infoCategory)
Exemplo n.º 26
0
    def _add_row(self, name, value):
        row = self.table.rowCount()
        self.table.setRowCount(row + 1)

        name = QTableWidgetItem(name)
        value = QTableWidgetItem(str(value))

        delete = QPushButton("X")
        delete.name_item = name
        delete.clicked.connect(self._delete)

        self.table.blockSignals(True)
        self.table.setItem(row, 0, name)
        self.table.setItem(row, 1, value)
        self.table.setCellWidget(row, 2, delete)
        self.table.blockSignals(False)
Exemplo n.º 27
0
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)

        self.setMinimumWidth(500)

        self.table = QTableWidget()
        self.table.setSelectionMode(QTableWidget.SingleSelection)
        self.table.itemChanged.connect(self._item_changed)
        self.table.currentItemChanged.connect(self._current_item_changed)
        self.table.horizontalHeader().hide()
        self.table.verticalHeader().hide()
        self.table.setColumnCount(3)
        self.table.horizontalHeader().resizeSection(0, 200)
        self.table.horizontalHeader().resizeSection(1, 200)
        self.table.horizontalHeader().resizeSection(2, 20)

        self.new = QPushButton('New variable')
        self.new.clicked.connect(self._new)

        self.color = Color()
        self.color.changed.connect(self._color_changed)

        layout = QGridLayout(self)
        layout.addWidget(self.table)
        layout.addWidget(self.color)
        layout.addWidget(self.new)
Exemplo n.º 28
0
    def __init__(self, parent=None):
        super().__init__(parent)

        self.m_icon = QLabel()
        self.m_title = QLabel()
        self.m_message = QLabel()

        self.notification = None

        self.setWindowFlags(Qt.ToolTip)
        rootLayout = QHBoxLayout(self)

        rootLayout.addWidget(self.m_icon)

        bodyLayout = QVBoxLayout()
        rootLayout.addLayout(bodyLayout)

        titleLayout = QHBoxLayout()
        bodyLayout.addLayout(titleLayout)

        titleLayout.addWidget(self.m_title)
        titleLayout.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding))

        close = QPushButton(self.tr("Close"))
        titleLayout.addWidget(close)
        close.clicked.connect(self.onClosed)

        bodyLayout.addWidget(self.m_message)
        self.adjustSize()
Exemplo n.º 29
0
    def __init__(self, *args, **kwargs):

        self._style = kwargs.pop('button_style', None)
        self._pad = kwargs.pop('icon_padding', 0)
        self._min_size = kwargs.pop('min_size', 8)
        self._radius = kwargs.pop('radius', 5)
        self._icon = kwargs.pop('icon', None)

        QPushButton.__init__(self, *args, **kwargs)
        animation.BaseAnimObject.__init__(self)

        self._font_metrics = QFontMetrics(self.font())
        self._border_width = kwargs.get('border_width')

        if self._icon:
            self.setIcon(self._icon)
Exemplo n.º 30
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)
Exemplo n.º 31
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 )