Пример #1
0
    def __init__(self, parent=None):
        super(UiMainWindow, self).__init__(parent)
        DispatchHandle.setup(self)

        self.showMaximized()
        self.setMinimumSize(QSize(640, 480))
        self.setDockOptions(QMainWindow.AnimatedDocks)
        self.setWindowTitle("SpecViz")

        self.widget_central = QWidget(self)
        self.setCentralWidget(self.widget_central)

        # Toolbar
        self.layout_vertical = QVBoxLayout(self.widget_central)

        # MDI area setup
        self.mdi_area = MdiArea(self.widget_central)
        self.mdi_area.setFrameShape(QFrame.StyledPanel)
        self.mdi_area.setFrameShadow(QFrame.Plain)
        self.mdi_area.setLineWidth(2)
        brush = QBrush(QColor(200, 200, 200))
        brush.setStyle(Qt.SolidPattern)
        self.mdi_area.setBackground(brush)
        self.mdi_area.setAcceptDrops(True)

        self.layout_vertical.addWidget(self.mdi_area)

        # Menu bar setup
        self.menu_bar = QMenuBar(self)

        self.menu_file = QMenu(self.menu_bar)
        self.menu_file.setTitle("File")
        self.menu_edit = QMenu(self.menu_bar)
        self.menu_edit.setTitle("Edit")
        self.menu_view = QMenu(self.menu_bar)
        self.menu_edit.setTitle("View")

        self.menu_docks = QMenu(self.menu_bar)

        self.setMenuBar(self.menu_bar)

        # Status bar setup
        self.status_bar = QStatusBar(self)

        self.setStatusBar(self.status_bar)
Пример #2
0
def test_construct(qtbot, command, title):
    """
    Test the construct of the widget.

    Expectations:
    The widget is initialized, and the commands and titles match the
    constructor arguments provided.  Also tests the icon and cursor pixmaps.

    Parameters
    ----------
    qtbot : fixture
        Window for widget testing
    command : str
        The shell command(s) to be executed when the widget is pressed
    title : str
        The titles for the shell commands.  Really only relevant if
        len(commands) > 1

    """
    pydm_shell_command = PyDMShellCommand(command=command, title=title)
    qtbot.addWidget(pydm_shell_command)
    if command and isinstance(command, str):
        assert pydm_shell_command._commands == [command]
    elif command:
        assert pydm_shell_command._commands == command
    else:
        assert pydm_shell_command._commands == []
    if title and isinstance(title, str):
        assert pydm_shell_command._titles == [title]
    elif title:
        assert pydm_shell_command._titles == title
    else:
        assert pydm_shell_command._titles == []

    DEFAULT_ICON_NAME = "cog"
    DEFAULT_ICON_SIZE = QSize(16, 16)

    default_icon = IconFont().icon(DEFAULT_ICON_NAME)

    default_icon_pixmap = default_icon.pixmap(DEFAULT_ICON_SIZE)
    shell_cmd_icon_pixmap = pydm_shell_command.icon().pixmap(DEFAULT_ICON_SIZE)

    assert shell_cmd_icon_pixmap.toImage() == default_icon_pixmap.toImage()
    assert pydm_shell_command.cursor().pixmap().toImage(
    ) == default_icon_pixmap.toImage()
Пример #3
0
    def __init__(self,
                 apiKey,
                 lat=0,
                 lng=0,
                 zoom=4,
                 heading=0,
                 tilt=0,
                 clickableIcons=True,
                 mapTypeId="terrain",
                 parent=None):
        super().__init__(parent)
        self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.updateGeometry()
        self.setMinimumSize(QSize(640, 480))
        self.settings().setAttribute(QWebEngineSettings.DeveloperExtrasEnabled,
                                     True)
        self.settings().setAttribute(QWebEngineSettings.JavascriptEnabled,
                                     True)
        self.settings().setAttribute(
            QWebEngineSettings.LocalContentCanAccessRemoteUrls, True)
        self.settings().setAttribute(
            QWebEngineSettings.LocalContentCanAccessFileUrls, True)

        self.linkClicked.connect(QDesktopServices.openUrl)

        self.mainFrame.addToJavaScriptWindowObject("qtwebview", self)
        url_path = os.path.join(os.path.abspath(os.path.dirname(__file__)),
                                "index.html")
        url = QUrl("file://{}".format(url_path))
        self.setUrl(url)
        self.loadFinished.connect(self._pageLoadFinished)
        self.webViewReady.connect(self._webViewReady)

        # properties
        self._apiKey = apiKey
        self._bounds = GoogleMapsLatLngBounds(0, 0, 0, 0)
        self._center = GoogleMapsLatLng(lat, lng)
        self._clickableIcons = clickableIcons
        self._zoom = zoom
        self._heading = heading
        self._tilt = tilt
        self._mapTypeId = mapTypeId
        #
        self._markers = []
        self._markerIdCounter = 0
Пример #4
0
 def minimumSizeHint(self):
     """
     Return a minimum size hint
     """
     sz = self.__data.text.textSize(self.font())
     mw = 2 * (self.frameWidth() + self.__data.margin)
     mh = mw
     indent = self.__data.indent
     if indent <= 0:
         indent = self.defaultIndent()
     if indent > 0:
         align = self.__data.text.renderFlags()
         if align & Qt.AlignLeft or align & Qt.AlignRight:
             mw += self.__data.indent
         elif align & Qt.AlignTop or align & Qt.AlignBottom:
             mh += self.__data.indent
     sz += QSizeF(mw, mh)
     return QSize(np.ceil(sz.width()), np.ceil(sz.height()))
Пример #5
0
    def data(self, index: QModelIndex, role: Qt.ItemDataRole):
        """Return data at `index` for the requested `role`.

        see https://doc.qt.io/qt-5/model-view-programming.html#item-roles
        """
        if role == Qt.EditRole:
            return index.data(Qt.UserRole).name
        if role == Qt.DecorationRole:  # thumbnail
            key_frame = index.data(Qt.UserRole)
            return QImage(
                key_frame.thumbnail,
                key_frame.thumbnail.shape[1],
                key_frame.thumbnail.shape[0],
                QImage.Format_RGBA8888,
            )
        if role == Qt.SizeHintRole:  # determines size of item
            return QSize(160, 34)
        return super().data(index, role)
Пример #6
0
    def __init__(self,
                 parent=None,
                 title=None,
                 location=ToolBarLocation.Top,
                 corner_widget=None):
        super().__init__(parent, title=title or '')
        self._set_corner_widget(corner_widget)
        self._icon_size = QSize(16, 16)

        # Setup
        self.setObjectName("main_widget_toolbar_{}".format(
            str(uuid.uuid4())[:8]))
        self.setFloatable(False)
        self.setMovable(False)
        self.setAllowedAreas(location)
        self.setContextMenuPolicy(Qt.PreventContextMenu)
        self.setIconSize(self._icon_size)
        self._setup_style()
Пример #7
0
    def __init__(self, *args, **kwargs):

        # Since the base class is frozen we must create this attribute
        # before calling super().__init__().
        self.max_texture_sizes = None
        self._last_theme_color = None
        self._background_color_override = None
        super().__init__(*args, **kwargs)

        # Call get_max_texture_sizes() here so that we query OpenGL right
        # now while we know a Canvas exists. Later calls to
        # get_max_texture_sizes() will return the same results because it's
        # using an lru_cache.
        self.max_texture_sizes = get_max_texture_sizes()

        self.events.ignore_callback_errors = False
        self.native.setMinimumSize(QSize(200, 200))
        self.context.set_depth_func('lequal')
Пример #8
0
    def __init__(self, params):
        MWB.__init__(self, params)
        QWidget.__init__(self)

        self.video_size = QSize(400, 300)
        self.timer = QTimer(self)
        self.capture = None

        self.image_label = QLabel()
        self.image_label.setFixedSize(self.video_size)

        self.main_layout = QVBoxLayout()
        self.main_layout.addWidget(self.image_label)
        self.setLayout(self.main_layout)

        self.setup_camera()

        self.resize(self.video_size)
Пример #9
0
    def __init__(self, parent=None):
        super().__init__(parent)
        uic.loadUi(self.MM_XYZ_STAGE, self)

        # button icons
        for attr, icon in [
            ("left_Button", "left_arrow_1_green.svg"),
            ("right_Button", "right_arrow_1_green.svg"),
            ("y_up_Button", "up_arrow_1_green.svg"),
            ("y_down_Button", "down_arrow_1_green.svg"),
            ("up_Button", "up_arrow_1_green.svg"),
            ("down_Button", "down_arrow_1_green.svg"),
            ("offset_up_Button", "up_arrow_1_green.svg"),
            ("offset_down_Button", "down_arrow_1_green.svg"),
        ]:
            btn = getattr(self, attr)
            btn.setIcon(QIcon(str(ICONS / icon)))
            btn.setIconSize(QSize(30, 30))
Пример #10
0
    def imageFiles(self, new_files):
        """
        JSON-formatted dictionary keyed on states (integers), with filenames
        of the image file to display for the state.

        Parameters
        ----------
        new_files : str
        """
        self._state_images_string = str(new_files)
        try:
            new_file_dict = json.loads(self._state_images_string)
        except Exception:
            self._state_images = {}
            return
        self._sizeHint = QSize(0, 0)
        parent_display = self.find_parent_display()
        base_path = os.path.dirname(parent_display.loaded_file())
        for (state, filename) in new_file_dict.items():
            file_path = find_file(filename, base_path=base_path)
            # First, lets try SVG.  We have to try SVG first, otherwise
            # QPixmap will happily load the SVG and turn it into a raster image.
            # Really annoying: We have to try to load the file as SVG,
            # and we expect it will fail often (because many images aren't SVG).
            # Qt prints a warning message to stdout any time SVG loading fails.
            # So we have to temporarily silence Qt warning messages here.
            qInstallMessageHandler(self.qt_message_handler)
            svg = QSvgRenderer()
            svg.repaintNeeded.connect(self.update)
            if svg.load(file_path):
                self._state_images[int(state)] = (filename, svg)
                self._sizeHint = self._sizeHint.expandedTo(svg.defaultSize())
                qInstallMessageHandler(None)
                continue
            qInstallMessageHandler(None)
            # SVG didn't work, lets try QPixmap
            image = QPixmap(file_path)
            if not image.isNull():
                self._state_images[int(state)] = (filename, image)
                self._sizeHint = self._sizeHint.expandedTo(image.size())
                continue
            # If we get this far, the file specified could not be loaded at all.
            logger.error("Could not load image: {}".format(filename))
            self._state_images[int(state)] = (filename, None)
Пример #11
0
    def data(self, index, role):
        """
        This is the main display class for the model.  Setting different
        display roles inside of this class will determine how the views
        will handle the model data

        INPUTS: QModelIndex, int
        OUTPUT: QVariant, strings are cast to QString which is a QVariant
        """
        if not index.isValid():
            return None

        item = index.internalPointer()

        if role == Qt.DisplayRole or role == Qt.EditRole:
            for i in range(self.columnCount(item)):
                if index.column() == i:
                    try:
                        return_val = item.columnData()[self._header_data[i]]
                    except KeyError:
                        return_val = None
                    return return_val

        # change style for disabled items
        if role == Qt.FontRole:
            #font = self.font()
            font = QApplication.font()
            font.setStrikeOut(not item.isEnabled())
            self.layoutChanged.emit()
            return font
            #self.setFont(0, font)
        # todo disabled item color
        if role == Qt.ForegroundRole:
            if item.isEnabled():
                color = QColor(*iColor["rgba_text"])
            else:
                color = QColor(*iColor["rgba_text_disabled"])
            return color

        elif role == Qt.BackgroundRole:
            return QColor(255, 0, 0, 255)

        if role == Qt.SizeHintRole:
            return QSize(self.item_width, self.item_height)
Пример #12
0
def test_construct(qtbot):
    """
    Test the construction of the widget.

    Expectations:
    All the default values are properly set.

    Parameters
    ----------
    qtbot : fixture
        pytest-qt window for widget test
    """
    widget = PyDMEnumButton()
    qtbot.addWidget(widget)

    assert widget._has_enums is False
    assert widget.orientation == Qt.Vertical
    assert widget.widgetType == WidgetType.PushButton
    assert widget.minimumSizeHint() == QSize(50, 100)
Пример #13
0
 def __init__(self, title: str, algorithm_data: Sequence[Mapping[str, Any]],
              parent: QWidget):
     """Add three tabs of chart."""
     super(ChartDialog, self).__init__(parent)
     self.setWindowTitle("Fitness-Generation-Time Charts")
     self.setWindowFlags(self.windowFlags() | Qt.WindowMaximizeButtonHint)
     self.setSizeGripEnabled(True)
     self.setModal(True)
     self.setMinimumSize(QSize(800, 600))
     self.title = title
     self.algorithm_data = algorithm_data
     # Widgets
     main_layout = QVBoxLayout(self)
     main_layout.setContentsMargins(6, 6, 6, 6)
     self.tab_widget = QTabWidget(self)
     self.__set_chart("F-G Plot", 0, 1, 'Generation', 'Fitness')
     self.__set_chart("G-T Plot", 2, 0, 'Time', 'Generation')
     self.__set_chart("F-T Plot", 2, 1, 'Time', 'Fitness')
     main_layout.addWidget(self.tab_widget)
Пример #14
0
    def __init__(self, parent=None, spinner=False):
        """Status bar widget base."""
        super().__init__(parent)

        # Variables
        self.value = None
        self._parent = parent

        # Widget
        self._icon = self.get_icon()
        self._pixmap = None
        self._icon_size = QSize(16, 16)  # Should this be adjustable?
        self.label_icon = QLabel()
        self.label_value = QLabel()
        self.spinner = None
        if spinner:
            self.spinner = create_waitspinner(size=14, parent=self)

        # Layout setup
        layout = QHBoxLayout(self)
        layout.setSpacing(0)  # Reduce space between icon and label
        layout.addWidget(self.label_icon)
        layout.addWidget(self.label_value)
        if spinner:
            layout.addWidget(self.spinner)
            self.spinner.hide()
        if is_dark_interface():
            layout.addSpacing(0)
        else:
            layout.addSpacing(10)
        layout.setContentsMargins(0, 0, 0, 0)

        # Widget setup
        self.set_icon()

        # See spyder-ide/spyder#9044.
        self.text_font = QFont(QFont().defaultFamily(), weight=QFont.Normal)
        self.label_value.setAlignment(Qt.AlignRight)
        self.label_value.setFont(self.text_font)

        # Setup
        self.set_value('')
        self.update_tooltip()
Пример #15
0
    def __init__(self, parent=None, title=None):
        super().__init__(parent, title=title or '')
        self._icon_size = QSize(16, 16)

        # Setup
        self.setObjectName("main_widget_toolbar_{}".format(
            str(uuid.uuid4())[:8]))
        self.setFloatable(False)
        self.setMovable(False)
        self.setContextMenuPolicy(Qt.PreventContextMenu)
        self.setIconSize(self._icon_size)

        self._style = ToolbarStyle(None)
        self._style.TYPE = 'MainWidget'
        self.setStyle(self._style)

        self.setStyleSheet(str(PANES_TOOLBAR_STYLESHEET))

        self._filter = ToolTipFilter()
Пример #16
0
    def __init__(self, *args, **kwargs):
        """Quit application confirmation dialog."""
        self.config = kwargs.pop('config', CONF)
        super(QuitApplicationDialog, self).__init__(*args, **kwargs)
        self.widget_icon = QSvgWidget(images.ANACONDA_LOGO)
        self.label_about = QLabel('Quit Anaconda Navigator?')
        self.button_ok = ButtonPrimary('Yes')
        self.button_cancel = ButtonNormal('No')
        self.buttonbox = QDialogButtonBox(Qt.Horizontal)
        self.checkbox = CheckBoxBase("Don't show again")

        # Widgets setup
        self.setWindowTitle("Quit application")
        self.widget_icon.setFixedSize(QSize(100, 100))

        # Layouts
        h_layout = QHBoxLayout()
        h_layout.addWidget(self.widget_icon, 0, Qt.AlignTop)
        h_layout.addWidget(SpacerHorizontal())
        h_layout.addWidget(self.label_about)

        layout_buttons = QHBoxLayout()
        layout_buttons.addStretch()
        layout_buttons.addWidget(self.button_cancel)
        layout_buttons.addWidget(SpacerHorizontal())
        layout_buttons.addWidget(self.button_ok)

        main_layout = QVBoxLayout()
        main_layout.addLayout(h_layout)
        main_layout.addWidget(self.checkbox, 0, Qt.AlignRight)
        main_layout.addWidget(SpacerVertical())
        main_layout.addWidget(SpacerVertical())
        main_layout.addLayout(layout_buttons)
        self.setLayout(main_layout)

        # Signals
        self.button_ok.clicked.connect(self.accept)
        self.button_cancel.clicked.connect(self.reject)

        # Setup
        self.update_style_sheet()
        self.setup()
        self.button_cancel.setFocus()
Пример #17
0
    def get_layer_icon(self, option, index):
        """Add the appropriate QIcon to the item based on the layer type."""
        layer = index.data(ItemRole)
        if hasattr(layer, 'is_group') and layer.is_group():  # for layer trees
            expanded = option.widget.isExpanded(index)
            icon_name = 'folder-open' if expanded else 'folder'
        else:
            icon_name = f'new_{layer._type_string}'

        try:
            icon = QColoredSVGIcon.from_resources(icon_name)
        except ValueError:
            return
        # guessing theme rather than passing it through.
        bg = option.palette.color(option.palette.Background).red()
        option.icon = icon.colored(theme='dark' if bg < 128 else 'light')
        option.decorationSize = QSize(18, 18)
        option.decorationPosition = option.Right  # put icon on the right
        option.features |= option.HasDecoration
Пример #18
0
    def __init__(self, parent=None):
        """Dialog for selection of installed system/user applications."""
        super(ApplicationsDialog, self).__init__(parent=parent)

        # Widgets
        self.label = QLabel()
        self.label_browse = QLabel()
        self.edit_filter = QLineEdit()
        self.list = QListWidget()
        self.button_browse = QPushButton(_('Browse...'))
        self.button_box = QDialogButtonBox(QDialogButtonBox.Ok
                                           | QDialogButtonBox.Cancel)
        self.button_ok = self.button_box.button(QDialogButtonBox.Ok)
        self.button_cancel = self.button_box.button(QDialogButtonBox.Cancel)

        # Widget setup
        self.setWindowTitle(_('Applications'))
        self.edit_filter.setPlaceholderText(_('Type to filter by name'))
        self.list.setIconSize(QSize(16, 16))  # FIXME: Use metrics

        # Layout
        layout = QVBoxLayout()
        layout.addWidget(self.label)
        layout.addWidget(self.edit_filter)
        layout.addWidget(self.list)
        layout_browse = QHBoxLayout()
        layout_browse.addWidget(self.button_browse)
        layout_browse.addWidget(self.label_browse)
        layout.addLayout(layout_browse)
        layout.addSpacing(12)  # FIXME: Use metrics
        layout.addWidget(self.button_box)
        self.setLayout(layout)

        # Signals
        self.edit_filter.textChanged.connect(self.filter)
        self.button_browse.clicked.connect(lambda x: self.browse())
        self.button_ok.clicked.connect(self.accept)
        self.button_cancel.clicked.connect(self.reject)
        self.list.currentItemChanged.connect(self._refresh)

        self._refresh()
        self.setup()
Пример #19
0
    def __init__(self, parent=None, show_fullpath=True, show_all_files=True,
                 group_cells=True, show_comments=True,
                 sort_files_alphabetically=False, display_variables=False,
                 follow_cursor=True, options_button=None):
        # TODO: Remove once the OutlineExplorer is migrated
        self.CONF_SECTION = 'outline_explorer'
        QWidget.__init__(self, parent)

        self.treewidget = OutlineExplorerTreeWidget(
            self,
            show_fullpath=show_fullpath,
            show_all_files=show_all_files,
            group_cells=group_cells,
            display_variables=display_variables,
            show_comments=show_comments,
            sort_files_alphabetically=sort_files_alphabetically,
            follow_cursor=follow_cursor,
            )
        self.loading_widget = create_waitspinner(size=16, parent=self)
        self.treewidget.sig_display_spinner.connect(self.loading_widget.start)
        self.treewidget.sig_hide_spinner.connect(self.loading_widget.stop)
        self.treewidget.sig_update_configuration.connect(
            self.sig_update_configuration)

        self.visibility_action = create_action(self,
                                           _("Show/hide outline explorer"),
                                           icon='outline_explorer_vis',
                                           toggled=self.toggle_visibility)
        self.visibility_action.setChecked(True)

        btn_layout = QHBoxLayout()
        for btn in self.setup_buttons():
            btn.setAutoRaise(True)
            btn.setIconSize(QSize(16, 16))
            btn_layout.addWidget(btn)
        if options_button:
            btn_layout.addStretch()
            btn_layout.addWidget(self.loading_widget, Qt.AlignRight)
            btn_layout.addWidget(options_button, Qt.AlignRight)

        layout = create_plugin_layout(btn_layout, self.treewidget)
        self.setLayout(layout)
Пример #20
0
    def title_mouse_release_event(self):
        self.set_state(DragState.inactive)
        if not self.drop_container:
            logger.debug('title_mouse_release_event: no drop container?')
            return

        dock_manager = self.dock_manager
        dock_area_overlay = dock_manager.dock_area_overlay()
        container_overlay = dock_manager.container_overlay()
        if any(widget.drop_area_under_cursor() != DockWidgetArea.invalid
               for widget in (dock_area_overlay, container_overlay)):
            # Resize the floating widget to the size of the highlighted drop area
            # rectangle
            overlay = container_overlay
            if not overlay.drop_overlay_rect().isValid():
                overlay = dock_area_overlay

            rect = overlay.drop_overlay_rect()
            if not rect.isValid():
                logger.debug('title_mouse_release_event: invalid rect '
                             'x %s y %s w %s h %s',
                             rect.x(), rect.y(),
                             rect.width(), rect.height())
            else:
                public = self.public
                frame_width = (public.frameSize().width() -
                               public.rect().width()) // 2
                title_bar_height = int(public.frameSize().height() -
                                       public.rect().height() - frame_width)

                top_left = overlay.mapToGlobal(rect.topLeft())
                top_left.setY(top_left.y() + title_bar_height)
                geom = QRect(top_left, QSize(rect.width(), rect.height() -
                                             title_bar_height))
                self.public.setGeometry(geom)
                qapp = QApplication.instance()
                qapp.processEvents()

            self.drop_container.drop_floating_widget(self.public, QCursor.pos())

        container_overlay.hide_overlay()
        dock_area_overlay.hide_overlay()
Пример #21
0
 def __init__(self, item) -> None:
     QGraphicsView.__init__(self)
     scene = QGraphicsScene(self)
     self.setScene(scene)
     item.setMinimumSize(QSize(150, 150))
     item.setMaximum(36000)
     item.setSingleStep(100)
     item.setPageStep(100)
     item.setInvertedAppearance(True)
     item.setWrapping(True)
     item.setNotchTarget(.1)
     item.setNotchesVisible(True)
     graphics_item = scene.addWidget(item)
     graphics_item.setRotation(-90)
     # make the QGraphicsView invisible.
     self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
     self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
     self.setFixedHeight(item.height())
     self.setFixedWidth(item.width())
     self.setStyleSheet("border: 0px;")
Пример #22
0
    def __init__(self):
        super(DataResourceBrowser, self).__init__()
        vbox = QVBoxLayout()
        vbox.setSpacing(0)
        vbox.setContentsMargins(0, 0, 0, 0)
        self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.setMinimumSize(QSize(250, 400))

        self.browsertabwidget = BrowserTabWidget(self)
        self.browsertabbar = BrowserTabBar(self.browsertabwidget)
        self.browsertabbar.sigAddBrowser.connect(self.addBrowser)
        self.browsertabbar.tabCloseRequested.connect(self.closetab)

        # Add the required 'Local' browser
        self.addBrowser(DataBrowser(LocalFileSystemTree()), "Local", closable=False)
        self.browsertabbar.setCurrentIndex(0)

        vbox.addWidget(self.browsertabwidget)

        self.setLayout(vbox)
Пример #23
0
    def setup_ui(self):
        uic.loadUi(self.UI_FILE, self)  # load QtDesigner .ui file

        # set some defaults
        self.cfg_LineEdit.setText("demo")

        # button icons
        for attr, icon in [
            ("left_Button", "left_arrow_1_green.svg"),
            ("right_Button", "right_arrow_1_green.svg"),
            ("y_up_Button", "up_arrow_1_green.svg"),
            ("y_down_Button", "down_arrow_1_green.svg"),
            ("up_Button", "up_arrow_1_green.svg"),
            ("down_Button", "down_arrow_1_green.svg"),
            ("snap_Button", "cam.svg"),
            ("live_Button", "vcam.svg"),
        ]:
            btn = getattr(self, attr)
            btn.setIcon(QIcon(str(ICONS / icon)))
            btn.setIconSize(QSize(30, 30))
Пример #24
0
 def add(self, item=None):
     """
     Return the text of all items in the list, except the current one being
     edited.
     """
     if item:
         if item.text() in self.get_texts() and not self.duplicates:
             raise Exception
         else:
             self.list.addItem(item)
     else:
         item = QListWidgetItem()
         item.extra_data = None
         item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable
                       | Qt.ItemIsEditable)
         self.list.addItem(item)
         self.list.setCurrentItem(item)
         item.setSizeHint(QSize(item.sizeHint().width(), self._height()))
         self.edit()
     self.refresh()
Пример #25
0
    def __init__(self, title: str, algorithm_data: Sequence[Dict[str, Any]],
                 parent: QWidget) -> None:
        """Add three tabs of chart."""
        super(ChartDialog, self).__init__(parent)
        self.setWindowTitle("Chart")
        self.setWindowFlags(self.windowFlags() | Qt.WindowMaximizeButtonHint)
        self.setSizeGripEnabled(True)
        self.setModal(True)
        self.setMinimumSize(QSize(800, 600))
        self.title = title
        self.algorithm_data = algorithm_data

        # Widgets
        main_layout = QVBoxLayout(self)
        main_layout.setContentsMargins(6, 6, 6, 6)
        self.tabWidget = QTabWidget(self)
        self.__set_chart("Fitness / Generation Chart", 0, 1)
        self.__set_chart("Generation / Time Chart", 2, 0)
        self.__set_chart("Fitness / Time Chart", 2, 1)
        main_layout.addWidget(self.tabWidget)
    def __init__(self, parent=None):
        super(mainWidget, self).__init__(parent)
        self.setMinimumSize(QSize(1000, 600))

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

        self.map = GoogleMapsView(self,
                                  "AIzaSyAEea-e9xrZGTn8AcAxds85uoxkASds-88")
        # self.map = GoogleMapsView(self, "AIzaSyAEea-e9xrZGTn8AcAxds85uoxkASds-88")
        self.map.showZoomControl(False)
        self.map.loadFinished.connect(self.test)

        self._layout.addWidget(self.map)

        self.btn = QPushButton(self)
        self.btn.setText("Change style")
        self.btn.clicked.connect(_change_style)
        self._layout.addWidget(self.btn)
Пример #27
0
    def _create_canvas(self) -> None:
        """Create the canvas and hook up events."""
        self.canvas = VispyCanvas(
            keys=None,
            vsync=True,
            parent=self,
            size=self.viewer._canvas_size[::-1],
        )
        self.canvas.events.ignore_callback_errors = False
        self.canvas.events.draw.connect(self.dims.enable_play)
        self.canvas.native.setMinimumSize(QSize(200, 200))
        self.canvas.context.set_depth_func('lequal')

        self.canvas.connect(self.on_mouse_move)
        self.canvas.connect(self.on_mouse_press)
        self.canvas.connect(self.on_mouse_release)
        self.canvas.connect(self._key_map_handler.on_key_press)
        self.canvas.connect(self._key_map_handler.on_key_release)
        self.canvas.connect(self.on_mouse_wheel)
        self.canvas.connect(self.on_draw)
        self.canvas.connect(self.on_resize)
Пример #28
0
 def add_test(self, fname):
     """Add new test"""
     if self.test_nb is None:
         self.test_nb = 0
     self.test_nb += 1
     row = (self.test_nb - 1) % self.ROWS
     column = (self.test_nb - 1) // self.ROWS
     bname = osp.basename(fname)
     button = QToolButton(self)
     button.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)
     shot = osp.join(TEST_PATH, "data", bname.replace(".py", ".png"))
     if osp.isfile(shot):
         button.setIcon(QIcon(shot))
     else:
         button.setIcon(self.get_std_icon("DialogYesButton"))
     button.setText(bname)
     button.setToolTip(fname)
     button.setIconSize(QSize(130, 80))
     button.clicked.connect(
         lambda checked=None, fname=fname: run_test(fname))
     self.grid_layout.addWidget(button, row, column)
Пример #29
0
    def __init__(self, parent=None, filename=None):
        QPushButton.__init__(self, parent)
        PyDMPrimitiveWidget.__init__(self)
        self.mouseReleaseEvent = self.push_button_release_event
        self.setContextMenuPolicy(Qt.CustomContextMenu)
        self.customContextMenuRequested.connect(self.show_context_menu)

        self.iconFont = IconFont()
        self._icon = self.iconFont.icon("file")
        self.setIconSize(QSize(16, 16))
        self.setIcon(self._icon)

        self.setCursor(QCursor(self._icon.pixmap(16, 16)))

        self._display_filename = filename
        self._macro_string = None
        self._open_in_new_window = False
        self.open_in_new_window_action = QAction("Open in New Window", self)
        self.open_in_new_window_action.triggered.connect(
            partial(self.open_display, self.NEW_WINDOW))
        self._show_icon = True
Пример #30
0
    def __init__(self, parent, statusbar, icon=None):
        """Status bar widget base."""
        super(StatusBarWidget, self).__init__(parent)

        # Variables
        self.value = None

        # Widget
        self._icon = icon
        self._pixmap = icon.pixmap(QSize(16, 16)) if icon is not None else None
        self.label_icon = QLabel() if icon is not None else None
        self.label_value = QLabel()

        # Widget setup
        if icon is not None:
            self.label_icon.setPixmap(self._pixmap)
        # See spyder-ide/spyder#9044.
        self.text_font = QFont(get_font(option='font'))
        self.text_font.setPointSize(self.font().pointSize())
        self.text_font.setBold(True)
        self.label_value.setAlignment(Qt.AlignRight)
        self.label_value.setFont(self.text_font)

        if self.TIP:
            self.setToolTip(self.TIP)
            self.label_value.setToolTip(self.TIP)

        # Layout
        layout = QHBoxLayout()
        if icon is not None:
            layout.addWidget(self.label_icon)
        layout.addWidget(self.label_value)
        layout.addSpacing(20)

        # Layout setup
        layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(layout)

        # Setup
        statusbar.addPermanentWidget(self)