Python qtpy.QtWidgets.QLabel() Examples

The following are 29 code examples of qtpy.QtWidgets.QLabel(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module qtpy.QtWidgets , or try the search function .
Example #1
Source File: base_module_widget.py    From pyrpl with GNU General Public License v3.0 6 votes vote down vote up
def create_title_bar(self):
        self.title_label = QtWidgets.QLabel("yo", parent=self)
         # title should be at the top-left corner of the widget
        self.load_label = LoadLabel(self)
        self.load_label.adjustSize()

        self.save_label = SaveLabel(self)
        self.save_label.adjustSize()

        self.erase_label = EraseLabel(self)
        self.erase_label.adjustSize()

        self.edit_label = EditLabel(self)
        self.edit_label.adjustSize()

        self.hideshow_label = HideShowLabel(self)
        self.hideshow_label.adjustSize()

        # self.setStyleSheet("ModuleWidget{border: 1px dashed gray;color: black;}")
        self.setStyleSheet("ModuleWidget{margin: 0.1em; margin-top:0.6em; border: 1 dotted gray;border-radius:5}")
        # margin-top large enough for border to be in the middle of title
        self.layout().setContentsMargins(0, 5, 0, 0) 
Example #2
Source File: QLinkableWidgets.py    From pylustrator with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, layout: QtWidgets.QLayout, text: str, values: Sequence):
        """ A combo box widget with a label

        Args:
            layout: the layout to which to add the widget
            text: the label text
            values: the possible values of the combo box
        """
        QtWidgets.QWidget.__init__(self)
        layout.addWidget(self)
        self.layout = QtWidgets.QHBoxLayout(self)
        self.label = QtWidgets.QLabel(text)
        self.layout.addWidget(self.label)
        self.layout.setContentsMargins(0, 0, 0, 0)

        self.values = values

        self.input1 = QtWidgets.QComboBox()
        self.input1.addItems(values)
        self.layout.addWidget(self.input1)

        self.input1.currentIndexChanged.connect(self.valueChangeEvent)
        self.layout.addWidget(self.input1) 
Example #3
Source File: QLinkableWidgets.py    From pylustrator with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, layout: QtWidgets.QLabel, text: str):
        """ a widget that contains a checkbox with a label

        Args:
            layout: the layout to which to add the widget
            text: the label text
        """
        QtWidgets.QWidget.__init__(self)
        layout.addWidget(self)
        self.layout = QtWidgets.QHBoxLayout(self)
        self.label = QtWidgets.QLabel(text)
        self.layout.addWidget(self.label)
        self.layout.setContentsMargins(0, 0, 0, 0)

        self.input1 = QtWidgets.QCheckBox()
        self.input1.setTristate(False)
        self.input1.stateChanged.connect(self.onStateChanged)
        self.layout.addWidget(self.input1) 
Example #4
Source File: schematics.py    From pyrpl with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, widget_name, y, label, parent, x_offset=0):
        super(MyItem, self).__init__()
        self.lay = QtWidgets.QVBoxLayout()
        self.setLayout(self.lay)
        self.item = QtWidgets.QLabel(label)
        self.setStyleSheet('background-color:transparent')
        self.lay.addWidget(self.item)

        self.widget_name = widget_name
        self.y = y
        self.x_offset = x_offset
        self.parent = parent
        parent.graphic_items.append(self)
        self.item.setStyleSheet(
            "QLabel{border: 1px solid black; border-radius: 5px; "
            "font-size: 15px; background-color:white}")
        self.proxy = parent.scene.addWidget(self)
        self.proxy.setZValue(2) 
Example #5
Source File: attribute_widgets.py    From pyrpl with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, module, attribute_name, widget_name=None):
        super(BaseAttributeWidget, self).__init__()
        self.module = module
        self.attribute_name = attribute_name
        if widget_name is None:
            self.widget_name = self.attribute_name
        else:
            self.widget_name = widget_name
        self.setToolTip(self.attribute_descriptor.__doc__)
        self.layout_v = QtWidgets.QVBoxLayout()
        self.layout = self.layout_v
        if self.widget_name != "":
            self.label = QtWidgets.QLabel(self.widget_name)
            self.layout.addWidget(self.label, 0) # stretch=0
            self.layout.addStretch(1)
        self.layout_v.setContentsMargins(0, 0, 0, 0)
        self._make_widget()
        self.layout.addWidget(self.widget, 0) # stretch=0
        self.layout.addStretch(1)
        self.setLayout(self.layout)
        self.write_attribute_value_to_widget()
        # this is very nice for debugging, but should probably be removed later
        setattr(self.module, '_'+self.attribute_name+'_widget', self) 
Example #6
Source File: qt_surface_layer.py    From napari with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def __init__(self, layer):
        super().__init__(layer)

        colormap_layout = QHBoxLayout()
        colormap_layout.addWidget(self.colorbarLabel)
        colormap_layout.addWidget(self.colormapComboBox)
        colormap_layout.addStretch(1)

        # grid_layout created in QtLayerControls
        # addWidget(widget, row, column, [row_span, column_span])
        self.grid_layout.addWidget(QLabel('opacity:'), 0, 0)
        self.grid_layout.addWidget(self.opacitySlider, 0, 1)
        self.grid_layout.addWidget(QLabel('contrast limits:'), 1, 0)
        self.grid_layout.addWidget(self.contrastLimitsSlider, 1, 1)
        self.grid_layout.addWidget(QLabel('gamma:'), 2, 0)
        self.grid_layout.addWidget(self.gammaSlider, 2, 1)
        self.grid_layout.addWidget(QLabel('colormap:'), 3, 0)
        self.grid_layout.addLayout(colormap_layout, 3, 1)
        self.grid_layout.addWidget(QLabel('blending:'), 4, 0)
        self.grid_layout.addWidget(self.blendComboBox, 4, 1)
        self.grid_layout.setRowStretch(5, 1)
        self.grid_layout.setColumnStretch(1, 1)
        self.grid_layout.setSpacing(4) 
Example #7
Source File: spinbox.py    From pyrpl with GNU General Public License v3.0 6 votes vote down vote up
def make_layout(self):
        self.lay = QtWidgets.QHBoxLayout()
        self.lay.setContentsMargins(0, 0, 0, 0)
        self.real = FloatSpinBox(label=self.labeltext,
                                 min=self.minimum,
                                 max=self.maximum,
                                 increment=self.singleStep,
                                 log_increment=self.log_increment,
                                 halflife_seconds=self.halflife_seconds,
                                 decimals=self.decimals)
        self.imag = FloatSpinBox(label=self.labeltext,
                                 min=self.minimum,
                                 max=self.maximum,
                                 increment=self.singleStep,
                                 log_increment=self.log_increment,
                                 halflife_seconds=self.halflife_seconds,
                                 decimals=self.decimals)
        self.real.value_changed.connect(self.value_changed)
        self.lay.addWidget(self.real)
        self.label = QtWidgets.QLabel(" + j")
        self.lay.addWidget(self.label)
        self.imag.value_changed.connect(self.value_changed)
        self.lay.addWidget(self.imag)
        self.setLayout(self.lay)
        self.setFocusPolicy(QtCore.Qt.ClickFocus) 
Example #8
Source File: __init__.py    From qtawesome with MIT License 6 votes vote down vote up
def font(prefix, size):
    """
    Return the font corresponding to the specified prefix.

    This can be used to render text using the iconic font directly::

        import qtawesome as qta
        from qtpy import QtWidgets

        label = QtWidgets.QLabel(unichr(0xf19c) + ' ' + 'Label')
        label.setFont(qta.font('fa', 16))

    Parameters
    ----------
    prefix: str
        prefix string of the loaded font
    size: int
        size for the font

    """
    return _instance().font(prefix, size) 
Example #9
Source File: QComplexWidgets.py    From pylustrator with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, axis: str, signal_target_changed: QtCore.Signal):
        """ A widget to change the tick properties

        Args:
            axis: whether to use the "x" or "y" axis
            signal_target_changed: a signal to emit when the target changed
        """
        QtWidgets.QWidget.__init__(self)
        self.setWindowTitle("Figure - " + axis + "-Axis - Ticks - Pylustrator")
        self.setWindowIcon(QtGui.QIcon(os.path.join(os.path.dirname(__file__), "icons", "ticks.ico")))
        self.layout = QtWidgets.QVBoxLayout(self)
        self.axis = axis

        self.label = QtWidgets.QLabel(
            "Ticks can be specified, one tick pre line.\nOptionally a label can be provided, e.g. 1 \"First\",")
        self.layout.addWidget(self.label)

        self.layout2 = QtWidgets.QHBoxLayout()
        self.layout.addLayout(self.layout2)

        self.input_ticks = TextWidget(self.layout2, axis + "-Ticks:", multiline=True, horizontal=False)
        self.input_ticks.editingFinished.connect(self.ticksChanged)

        self.input_ticks2 = TextWidget(self.layout2, axis + "-Ticks (minor):", multiline=True, horizontal=False)
        self.input_ticks2.editingFinished.connect(self.ticksChanged2)

        self.input_scale = ComboWidget(self.layout, axis + "-Scale", ["linear", "log", "symlog", "logit"])
        self.input_scale.link(axis + "scale", signal_target_changed)

        self.input_font = TextPropertiesWidget(self.layout)

        self.input_labelpad = NumberWidget(self.layout, axis + "-Labelpad", min=-999)
        self.input_labelpad.link(axis + "axis.labelpad", signal_target_changed, direct=True)

        self.button_ok = QtWidgets.QPushButton("Ok")
        self.layout.addWidget(self.button_ok)
        self.button_ok.clicked.connect(self.hide) 
Example #10
Source File: viewer.py    From pydiq with MIT License 5 votes vote down vote up
def show_structure(self):
        if self.file_name:
            f = pydicom.read_file(self.file_name)
            l = QtWidgets.QLabel(str(f))
            l.show()
            # print(str(f)) 
Example #11
Source File: acquisition_module_widget.py    From pyrpl with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent=None):
        super(CurrentAvgLabel, self).__init__(parent)
        self.main_lay = QtWidgets.QVBoxLayout()
        self.setLayout(self.main_lay)
        self.label = QtWidgets.QLabel("current_avg")
        self.main_lay.addWidget(self.label)
        self.value_label = QtWidgets.QLabel("0 /")
        self.main_lay.addWidget(self.value_label)
        self.main_lay.addStretch(1)
        self.value_label.setAlignment(QtCore.Qt.AlignCenter)
        self.main_lay.setContentsMargins(0,0,0,0) 
Example #12
Source File: lockbox_widget.py    From pyrpl with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent):
        super(AnalogTfSpec, self).__init__(parent)
        self.parent = parent
        self.module = self.parent.module
        self.layout = QtWidgets.QVBoxLayout(self)
        self.label = QtWidgets.QLabel("Analog transfer function")
        self.layout.addWidget(self.label)
        self.button = QtWidgets.QPushButton('Change...')
        self.layout.addWidget(self.button)
        self.button.clicked.connect(self.change)
        self.dialog = AnalogTfDialog(self)
        self.layout.setContentsMargins(0,0,0,0)
        self.change_analog_tf() 
Example #13
Source File: schematics.py    From pyrpl with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, widget_name, y, filename, label, parent, x_offset=0):
        super(MyImage, self).__init__(widget_name, y, label, parent, x_offset)
        self.pixmap = QtGui.QPixmap(osp.join(IMAGE_PATH, filename))
        self.item.setPixmap(self.pixmap)
        self.item.setFixedSize(self.pixmap.size())

        self.label = QtWidgets.QLabel(label)
        self.lay.addWidget(self.label)


        #self.setText(self.widget_name) 
Example #14
Source File: spinbox.py    From pyrpl with GNU General Public License v3.0 5 votes vote down vote up
def make_layout(self):
        self.lay = QtWidgets.QHBoxLayout()
        self.lay.setContentsMargins(0,0,0,0)
        self.lay.setSpacing(0)
        self.setLayout(self.lay)
        if self.labeltext is not None:
            self.label = QtWidgets.QLabel(self.labeltext)
            self.lay.addWidget(self.label)
        if self.log_increment:
            self.up = QtWidgets.QPushButton('*')
            self.down = QtWidgets.QPushButton('/')
        else:
            self.up = QtWidgets.QPushButton('+')
            self.down = QtWidgets.QPushButton('-')
        self.line = QtWidgets.QLineEdit()
        self.line.setStyleSheet("QLineEdit { qproperty-cursorPosition: 0; }") # align text on the left
        # http://stackoverflow.com/questions/18662157/qt-qlineedit-widget-to-get-long-text-left-aligned
        self.lay.addWidget(self.down)
        self.lay.addWidget(self.line)
        self.lay.addWidget(self.up)
        self.up.setMaximumWidth(15)
        self.down.setMaximumWidth(15)
        self.up.pressed.connect(self.first_step)
        self.down.pressed.connect(self.first_step)
        self.up.released.connect(self.finish_step)
        self.down.released.connect(self.finish_step)
        self.line.editingFinished.connect(self.validate)
        self._button_up_down = False
        self._button_down_down = False

    # keyboard interface 
Example #15
Source File: lineprofiler.py    From spyder-line-profiler with MIT License 5 votes vote down vote up
def setup_page(self):
        settings_group = QGroupBox(_("Settings"))
        use_color_box = self.create_checkbox(
            _("Use deterministic colors to differentiate functions"),
            'use_colors', default=True)

        results_group = QGroupBox(_("Results"))
        results_label1 = QLabel(_("Line profiler plugin results "
                                  "(the output of kernprof.py)\n"
                                  "are stored here:"))
        results_label1.setWordWrap(True)

        # Warning: do not try to regroup the following QLabel contents with
        # widgets above -- this string was isolated here in a single QLabel
        # on purpose: to fix Issue 863 of Profiler plugon
        results_label2 = QLabel(LineProfilerWidget.DATAPATH)

        results_label2.setTextInteractionFlags(Qt.TextSelectableByMouse)
        results_label2.setWordWrap(True)

        settings_layout = QVBoxLayout()
        settings_layout.addWidget(use_color_box)
        settings_group.setLayout(settings_layout)

        results_layout = QVBoxLayout()
        results_layout.addWidget(results_label1)
        results_layout.addWidget(results_label2)
        results_group.setLayout(results_layout)

        vlayout = QVBoxLayout()
        vlayout.addWidget(settings_group)
        vlayout.addWidget(results_group)
        vlayout.addStretch(1)
        self.setLayout(vlayout) 
Example #16
Source File: calcdialog.py    From mnelab with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __init__(self, parent, title, message):
        super().__init__(parent)
        self.setWindowTitle(title)
        vbox = QVBoxLayout(self)
        label = QLabel(message)
        button = QDialogButtonBox(QDialogButtonBox.Cancel)
        button.rejected.connect(self.close)
        vbox.addWidget(label)
        vbox.addWidget(button) 
Example #17
Source File: FileRevisionWindow.py    From P4VFX with MIT License 5 votes vote down vote up
def setRevisionTableColumn(self, row, column, value, icon=None, isLongText=False):
        value = str(value)

        widget = QtWidgets.QWidget()
        layout = QtWidgets.QHBoxLayout()
        layout.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignHCenter)

        # Use a QLineEdit to allow the text to be copied if the data is large
        if isLongText:
            textLabel = QtWidgets.QLineEdit()
            textLabel.setText(value)
            textLabel.setCursorPosition(0)
            textLabel.setReadOnly(True)
            textLabel.setStyleSheet("QLineEdit { border: none }")
        else:
            textLabel = QtWidgets.QLabel(value)
            textLabel.setStyleSheet("QLabel { border: none } ")

        # layout.setContentsMargins(4, 0, 4, 0)
        
        if icon:
            iconPic = QtGui.QPixmap(icon)
            iconPic = iconPic.scaled(16, 16)
            iconLabel = QtWidgets.QLabel()
            iconLabel.setPixmap(iconPic)
            layout.addWidget(iconLabel)
        layout.addWidget(textLabel)

        widget.setLayout(layout)

        self.tableWidget.setCellWidget(row, column, widget) 
Example #18
Source File: FileRevisionWindow.py    From P4VFX with MIT License 5 votes vote down vote up
def setRevisionTableColumn(self, row, column, value, icon=None, isLongText=False):
        value = str(value)

        widget = QtWidgets.QWidget()
        layout = QtWidgets.QHBoxLayout()
        layout.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignHCenter)

        # Use a QLineEdit to allow the text to be copied if the data is large
        if isLongText:
            textLabel = QtWidgets.QLineEdit()
            textLabel.setText(value)
            textLabel.setCursorPosition(0)
            textLabel.setReadOnly(True)
            textLabel.setStyleSheet("QLineEdit { border: none }")
        else:
            textLabel = QtWidgets.QLabel(value)
            textLabel.setStyleSheet("QLabel { border: none } ")

        # layout.setContentsMargins(4, 0, 4, 0)
        
        if icon:
            iconPic = QtGui.QPixmap(icon)
            iconPic = iconPic.scaled(16, 16)
            iconLabel = QtWidgets.QLabel()
            iconLabel.setPixmap(iconPic)
            layout.addWidget(iconLabel)
        layout.addWidget(textLabel)

        widget.setLayout(layout)

        self.tableWidget.setCellWidget(row, column, widget) 
Example #19
Source File: qt_plugin_table.py    From napari with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __init__(self, parent, plugin_manager=None):
        super().__init__(parent)
        if not plugin_manager:
            from ..plugins import plugin_manager

        self.setMaximumHeight(800)
        self.setMaximumWidth(1280)
        layout = QVBoxLayout()
        # maybe someday add a search bar here?
        title = QLabel("Installed Plugins")
        title.setObjectName("h2")
        layout.addWidget(title)
        # get metadata for successfully registered plugins
        plugin_manager.discover()
        data = plugin_manager.list_plugin_metadata()
        data = list(filter(lambda x: x['plugin_name'] != 'builtins', data))
        # create a table for it
        self.table = QtDictTable(
            parent,
            data,
            headers=[
                'plugin_name',
                'package',
                'version',
                'url',
                'author',
                'license',
            ],
            min_section_width=60,
        )
        self.table.setObjectName("pluginTable")
        self.table.horizontalHeader().setObjectName("pluginTableHeader")
        self.table.verticalHeader().setObjectName("pluginTableHeader")
        self.table.setGridStyle(Qt.NoPen)
        # prevent editing of table
        self.table.setEditTriggers(QAbstractItemView.NoEditTriggers)
        layout.addWidget(self.table)
        self.setLayout(layout)
        self.setAttribute(Qt.WA_DeleteOnClose) 
Example #20
Source File: multithreading_simple.py    From napari with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def create_widget():
    widget = QWidget()
    layout = QHBoxLayout()
    widget.setLayout(layout)
    widget.status = QLabel('ready...')
    layout.addWidget(widget.status)
    widget.show()
    return widget 
Example #21
Source File: QLinkableWidgets.py    From pylustrator with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, layout: QtWidgets.QLayout, text: str = None, value: str = None):
        """ A colored button what acts as an color input

        Args:
            layout: the layout to which to add the widget
            text: the label text
            value: the value of the color widget
        """
        super().__init__()
        self.layout = QtWidgets.QHBoxLayout(self)
        self.layout.setContentsMargins(0, 0, 0, 0)
        layout.addWidget(self)

        if text is not None:
            self.label = QtWidgets.QLabel(text)
            self.layout.addWidget(self.label)

        self.button = QtWidgets.QPushButton()
        self.layout.addWidget(self.button)

        self.button.clicked.connect(self.OpenDialog)
        # default value for the color
        if value is None:
            value = "#FF0000FF"
        # set the color
        self.setColor(value)

        self.editingFinished = self.valueChanged 
Example #22
Source File: QLinkableWidgets.py    From pylustrator with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, layout: QtWidgets.QLayout, text: str, multiline: bool = False, horizontal: bool = True):
        """ a text input widget with a label.

        Args:
            layout: the layout to which to add the widget
            text: the label text
            multiline: whether the text input should be a single line or not
            horizontal:  whether the layout should be left or above the input
        """
        QtWidgets.QWidget.__init__(self)
        layout.addWidget(self)
        if horizontal:
            self.layout = QtWidgets.QHBoxLayout(self)
        else:
            self.layout = QtWidgets.QVBoxLayout(self)
        self.label = QtWidgets.QLabel(text)
        self.layout.addWidget(self.label)
        self.layout.setContentsMargins(0, 0, 0, 0)

        self.multiline = multiline
        if multiline:
            self.input1 = QtWidgets.QTextEdit()
            self.input1.textChanged.connect(self.valueChangeEvent)
            self.input1.text = self.input1.toPlainText
        else:
            self.input1 = QtWidgets.QLineEdit()
            self.input1.editingFinished.connect(self.valueChangeEvent)
        self.layout.addWidget(self.input1) 
Example #23
Source File: targets_ui.py    From Pyslvs-UI with GNU Affero General Public License v3.0 4 votes vote down vote up
def setupUi(self, Dialog):
        Dialog.setObjectName("Dialog")
        Dialog.resize(346, 309)
        Dialog.setSizeGripEnabled(True)
        Dialog.setModal(True)
        self.verticalLayout_4 = QtWidgets.QVBoxLayout(Dialog)
        self.verticalLayout_4.setObjectName("verticalLayout_4")
        self.main_label = QtWidgets.QLabel(Dialog)
        self.main_label.setObjectName("main_label")
        self.verticalLayout_4.addWidget(self.main_label)
        self.horizontalLayout = QtWidgets.QHBoxLayout()
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.verticalLayout_3 = QtWidgets.QVBoxLayout()
        self.verticalLayout_3.setObjectName("verticalLayout_3")
        self.other_label = QtWidgets.QLabel(Dialog)
        self.other_label.setObjectName("other_label")
        self.verticalLayout_3.addWidget(self.other_label)
        self.other_list = QtWidgets.QListWidget(Dialog)
        self.other_list.setObjectName("other_list")
        self.verticalLayout_3.addWidget(self.other_list)
        self.horizontalLayout.addLayout(self.verticalLayout_3)
        self.verticalLayout = QtWidgets.QVBoxLayout()
        self.verticalLayout.setObjectName("verticalLayout")
        self.targets_add = QtWidgets.QPushButton(Dialog)
        self.targets_add.setMaximumSize(QtCore.QSize(30, 16777215))
        self.targets_add.setObjectName("targets_add")
        self.verticalLayout.addWidget(self.targets_add)
        self.other_add = QtWidgets.QPushButton(Dialog)
        self.other_add.setMaximumSize(QtCore.QSize(30, 16777215))
        self.other_add.setObjectName("other_add")
        self.verticalLayout.addWidget(self.other_add)
        self.horizontalLayout.addLayout(self.verticalLayout)
        self.verticalLayout_2 = QtWidgets.QVBoxLayout()
        self.verticalLayout_2.setObjectName("verticalLayout_2")
        self.targets_label = QtWidgets.QLabel(Dialog)
        self.targets_label.setObjectName("targets_label")
        self.verticalLayout_2.addWidget(self.targets_label)
        self.targets_list = QtWidgets.QListWidget(Dialog)
        self.targets_list.setObjectName("targets_list")
        self.verticalLayout_2.addWidget(self.targets_list)
        self.horizontalLayout.addLayout(self.verticalLayout_2)
        self.verticalLayout_4.addLayout(self.horizontalLayout)
        self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")
        spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout_2.addItem(spacerItem)
        self.button_box = QtWidgets.QDialogButtonBox(Dialog)
        self.button_box.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
        self.button_box.setObjectName("button_box")
        self.horizontalLayout_2.addWidget(self.button_box)
        self.verticalLayout_4.addLayout(self.horizontalLayout_2)

        self.retranslateUi(Dialog)
        self.button_box.accepted.connect(Dialog.accept)
        self.button_box.rejected.connect(Dialog.reject)
        QtCore.QMetaObject.connectSlotsByName(Dialog) 
Example #24
Source File: FileRevisionWindow.py    From P4VFX with MIT License 4 votes vote down vote up
def create_controls(self):
        '''
        Create the widgets for the dialog
        '''
        self.descriptionWidget = QtWidgets.QPlainTextEdit("<Enter Description>")
        self.descriptionLabel = QtWidgets.QLabel("Change Description:")
        self.getRevisionBtn = QtWidgets.QPushButton("Revert to Selected Revision")
        self.getLatestBtn = QtWidgets.QPushButton("Sync to Latest Revision")
        self.getPreviewBtn = QtWidgets.QPushButton("Preview Scene")
        self.getPreviewBtn.setEnabled(False)

        self.getRevisionBtn.setVisible(False)
        self.getLatestBtn.setVisible(False)
        self.getPreviewBtn.setVisible(False)

        # self.root = "//{0}".format(self.p4.client)
        # self.root = "//depot"
        # self.model = DepotClientViewModel.PerforceItemModel(self.p4)
        # self.model.populate(self.root, showDeleted=False)
        # self.model.populate('//depot', showDeleted=True)

        self.fileTree = QtWidgets.QTreeView()
        self.fileTree.expandAll()
        # self.fileTree.setModel(self.model)

        self.fileTree.setColumnWidth(0, 220)
        self.fileTree.setColumnWidth(1, 100)
        self.fileTree.setColumnWidth(2, 120)
        self.fileTree.setColumnWidth(3, 60)

        self.fileTree.setModel(self.model)
        # self.fileTree.setRootIndex(self.model.index(self.p4.cwd))
        self.fileTree.setColumnWidth(0, 180)

        headers = ["Revision", "User", "Action",
                   "Date", "Client", "Description"]

        self.tableWidget = QtWidgets.QTableWidget()
        self.tableWidget.setColumnCount(len(headers))
        self.tableWidget.setMaximumHeight(200)
        self.tableWidget.setMinimumWidth(500)
        self.tableWidget.setHorizontalHeaderLabels(headers)
        self.tableWidget.verticalHeader().setVisible(False)
        self.tableWidget.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
        self.tableWidget.setSelectionMode(QtWidgets.QAbstractItemView.SingleSelection)

        self.statusBar = QtWidgets.QStatusBar()
        # self.statusBar.showMessage("Test")

        self.horizontalLine = QtWidgets.QFrame()
        # self.horizontalLine.setFrameShape(QtWidgets.QFrame.Shape.HLine)

        if interop.getCurrentSceneFile():
            # self.fileTree.setCurrentIndex(self.model.index(interop.getCurrentSceneFile()))
            self.populateFileRevisions() 
Example #25
Source File: FileRevisionWindow.py    From P4VFX with MIT License 4 votes vote down vote up
def create_controls(self):
        '''
        Create the widgets for the dialog
        '''
        self.descriptionWidget = QtWidgets.QPlainTextEdit("<Enter Description>")
        self.descriptionLabel = QtWidgets.QLabel("Change Description:")
        self.getRevisionBtn = QtWidgets.QPushButton("Revert to Selected Revision")
        self.getLatestBtn = QtWidgets.QPushButton("Sync to Latest Revision")
        self.getPreviewBtn = QtWidgets.QPushButton("Preview Scene")
        self.getPreviewBtn.setEnabled(False)

        self.getRevisionBtn.setVisible(False)
        self.getLatestBtn.setVisible(False)
        self.getPreviewBtn.setVisible(False)

        # self.root = "//{0}".format(self.p4.client)
        # self.root = "//depot"
        # self.model = DepotClientViewModel.PerforceItemModel(self.p4)
        # self.model.populate(self.root, showDeleted=False)
        # self.model.populate('//depot', showDeleted=True)

        self.fileTree = QtWidgets.QTreeView()
        self.fileTree.expandAll()
        # self.fileTree.setModel(self.model)

        self.fileTree.setColumnWidth(0, 220)
        self.fileTree.setColumnWidth(1, 100)
        self.fileTree.setColumnWidth(2, 120)
        self.fileTree.setColumnWidth(3, 60)

        self.fileTree.setModel(self.model)
        # self.fileTree.setRootIndex(self.model.index(self.p4.cwd))
        self.fileTree.setColumnWidth(0, 180)

        headers = ["Revision", "User", "Action",
                   "Date", "Client", "Description"]

        self.tableWidget = QtWidgets.QTableWidget()
        self.tableWidget.setColumnCount(len(headers))
        self.tableWidget.setMaximumHeight(200)
        self.tableWidget.setMinimumWidth(500)
        self.tableWidget.setHorizontalHeaderLabels(headers)
        self.tableWidget.verticalHeader().setVisible(False)
        self.tableWidget.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
        self.tableWidget.setSelectionMode(QtWidgets.QAbstractItemView.SingleSelection)

        self.statusBar = QtWidgets.QStatusBar()
        # self.statusBar.showMessage("Test")

        self.horizontalLine = QtWidgets.QFrame()
        # self.horizontalLine.setFrameShape(QtWidgets.QFrame.Shape.HLine)

        if interop.getCurrentSceneFile():
            # self.fileTree.setCurrentIndex(self.model.index(interop.getCurrentSceneFile()))
            self.populateFileRevisions() 
Example #26
Source File: qt_image_base_layer.py    From napari with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
def __init__(self, layer):
        super().__init__(layer)

        self.events.add(
            colormap=Event,
            contrast_limits=Event,
            contrast_limits_range=Event,
            gamma=Event,
        )

        comboBox = QComboBox(self)
        comboBox.setObjectName("colormapComboBox")
        comboBox.activated[str].connect(self.events.colormap)
        self.colormapComboBox = comboBox

        # Create contrast_limits slider
        self.contrastLimitsSlider = QHRangeSlider(parent=self)
        self.contrastLimitsSlider.mousePressEvent = self._clim_mousepress
        self.contrastLimitsSlider.valuesChanged.connect(
            self.events.contrast_limits
        )
        self.contrastLimitsSlider.rangeChanged.connect(
            self.events.contrast_limits_range
        )

        # gamma slider
        sld = QSlider(Qt.Horizontal, parent=self)
        sld.setFocusPolicy(Qt.NoFocus)
        sld.setMinimum(2)
        sld.setMaximum(200)
        sld.setSingleStep(2)
        sld.setValue(100)
        sld.valueChanged.connect(lambda value: self.events.gamma(value / 100))
        self.gammaSlider = sld

        self.colorbarLabel = QLabel(parent=self)
        self.colorbarLabel.setObjectName('colorbar')
        self.colorbarLabel.setToolTip('Colorbar')

        # Once EVH refactor is done, these can be moved to an initialization
        # outside of this object
        self._on_gamma_change(self.layer.gamma)
        self._set_colormaps(self.layer.colormaps)
        self._on_colormap_change(self.layer.colormap[0])
        self._on_contrast_limits_range_change(self.layer.contrast_limits_range)
        self._on_contrast_limits_change(self.layer.contrast_limits) 
Example #27
Source File: QLinkableWidgets.py    From pylustrator with GNU General Public License v3.0 4 votes vote down vote up
def __init__(self, layout: QtWidgets.QLayout, text: str, join: str, unit: str, free: bool = False):
        """ a widget that lets the user input a pair of dimensions (e.g. widh and height)

        Args:
            layout: the layout to which to add the widget
            text: the label of the widget
            join: a text between the two parts
            unit: a unit for the values
            free: whether to use free number input widgets instead of QSpinBox
        """
        QtWidgets.QWidget.__init__(self)
        layout.addWidget(self)
        self.layout = QtWidgets.QHBoxLayout(self)
        self.text = QtWidgets.QLabel(text)
        self.layout.addWidget(self.text)
        self.layout.setContentsMargins(0, 0, 0, 0)

        if free:
            self.input1 = FreeNumberInput()
        else:
            self.input1 = QtWidgets.QDoubleSpinBox()
            self.input1.setSuffix(" " + unit)
            self.input1.setSingleStep(0.1)
            self.input1.setMaximum(99999)
            self.input1.setMinimum(-99999)
        self.input1.valueChanged.connect(self.onValueChanged)
        self.layout.addWidget(self.input1)

        self.text2 = QtWidgets.QLabel(join)
        self.text2.setMaximumWidth(self.text2.fontMetrics().width(join))
        self.layout.addWidget(self.text2)

        if free:
            self.input2 = FreeNumberInput()
        else:
            self.input2 = QtWidgets.QDoubleSpinBox()
            self.input2.setSuffix(" " + unit)
            self.input2.setSingleStep(0.1)
            self.input2.setMaximum(99999)
            self.input2.setMinimum(-99999)
        self.input2.valueChanged.connect(self.onValueChanged)
        self.layout.addWidget(self.input2)

        self.editingFinished = self.valueChanged 
Example #28
Source File: QtShortCuts.py    From pylustrator with GNU General Public License v3.0 4 votes vote down vote up
def __init__(self, parent: QtWidgets.QWidget, map):
        """ initialize the dialog with all the colormap of matplotlib """
        QtWidgets.QDialog.__init__(self, parent)
        main_layout = QtWidgets.QVBoxLayout(self)
        self.layout = QtWidgets.QHBoxLayout()
        main_layout.addLayout(self.layout)
        button_layout = QtWidgets.QHBoxLayout()
        main_layout.addLayout(button_layout)
        self.button_cancel = QtWidgets.QPushButton("Cancel")
        self.button_cancel.clicked.connect(lambda x: self.done(0))
        button_layout.addStretch()
        button_layout.addWidget(self.button_cancel)

        self.maps = plt.colormaps()
        self.buttons = []
        self.setWindowTitle("Select colormap")

        # Have colormaps separated into categories:
        # http://matplotlib.org/examples/color/colormaps_reference.html
        cmaps = [('Perceptually Uniform Sequential', [
            'viridis', 'plasma', 'inferno', 'magma']),
                 ('Sequential', [
                     'Greys', 'Purples', 'Blues', 'Greens', 'Oranges', 'Reds',
                     'YlOrBr', 'YlOrRd', 'OrRd', 'PuRd', 'RdPu', 'BuPu',
                     'GnBu', 'PuBu', 'YlGnBu', 'PuBuGn', 'BuGn', 'YlGn']),
                 ('Sequential (2)', [
                     'binary', 'gist_yarg', 'gist_gray', 'gray', 'bone', 'pink',
                     'spring', 'summer', 'autumn', 'winter', 'cool', 'Wistia',
                     'hot', 'afmhot', 'gist_heat', 'copper']),
                 ('Diverging', [
                     'PiYG', 'PRGn', 'BrBG', 'PuOr', 'RdGy', 'RdBu',
                     'RdYlBu', 'RdYlGn', 'Spectral', 'coolwarm', 'bwr', 'seismic']),
                 ('Qualitative', [
                     'Pastel1', 'Pastel2', 'Paired', 'Accent',
                     'Dark2', 'Set1', 'Set2', 'Set3',
                     'tab10', 'tab20', 'tab20b', 'tab20c']),
                 ('Miscellaneous', [
                     'flag', 'prism', 'ocean', 'gist_earth', 'terrain', 'gist_stern',
                     'gnuplot', 'gnuplot2', 'CMRmap', 'cubehelix', 'brg', 'hsv',
                     'gist_rainbow', 'rainbow', 'jet', 'nipy_spectral', 'gist_ncar'])]

        for cmap_category, cmap_list in cmaps:
            layout = QtWidgets.QVBoxLayout(self)
            label = QtWidgets.QLabel(cmap_category)
            layout.addWidget(label)
            label.setFixedWidth(150)
            for cmap in cmap_list:
                button = QtWidgets.QPushButton(cmap)
                button.setStyleSheet("text-align: center; border: 2px solid black; "+self.getBackground(cmap))
                button.clicked.connect(lambda x, cmap=cmap: self.buttonClicked(cmap))
                self.buttons.append(button)
                layout.addWidget(button)
            layout.addStretch()
            self.layout.addLayout(layout) 
Example #29
Source File: QComplexWidgets.py    From pylustrator with GNU General Public License v3.0 4 votes vote down vote up
def __init__(self, layout: QtWidgets.QLayout):
        """ A widget that allows to change to properties of a matplotlib legend

        Args:
            layout: the layout to which to add the widget
        """
        QtWidgets.QWidget.__init__(self)
        layout.addWidget(self)
        self.layout = QtWidgets.QVBoxLayout(self)
        self.layout.setContentsMargins(0, 0, 0, 0)

        self.property_names = [
            ("frameon", "frameon", bool, None),
            ("borderpad", "borderpad", float, None),
            ("labelspacing", "labelspacing", float, None),
            ("handlelength", "handlelength", float, None),
            ("handletextpad", "handletextpad", float, None),
            ("columnspacing", "columnspacing", float, None),
            ("markerscale", "markerscale", float, None),
            ("ncol", "_ncol", int, 1),
            ("title", "title", str, ""),
            ("fontsize", "_fontsize", int, None),
            ("title_fontsize", "title_fontsize", int, None),
        ]
        self.properties = {}

        self.widgets = {}
        for index, (name, name2, type_, default_) in enumerate(self.property_names):
            if index % 3 == 0:
                layout = QtWidgets.QHBoxLayout()
                layout.setContentsMargins(0, 0, 0, 0)
                self.layout.addLayout(layout)
            if type_ == bool:
                widget = CheckWidget(layout, name + ":")
                widget.editingFinished.connect(
                    lambda name=name, widget=widget: self.changePropertiy(name, widget.get()))
            elif type_ == str:
                widget = TextWidget(layout, name + ":")
                widget.editingFinished.connect(
                    lambda name=name, widget=widget: self.changePropertiy(name, widget.get()))
            else:
                label = QtWidgets.QLabel(name + ":")
                layout.addWidget(label)
                if type_ == float:
                    widget = QtWidgets.QDoubleSpinBox()
                    widget.setSingleStep(0.1)
                elif type_ == int:
                    widget = QtWidgets.QSpinBox()
                layout.addWidget(widget)
                widget.valueChanged.connect(lambda x, name=name: self.changePropertiy(name, x))
            self.widgets[name] = widget