Beispiel #1
0
def test():
    from anaconda_navigator.utils.qthelpers import qapplication
    app = qapplication()
    dlg = AboutDialog(parent=None)
    dlg.setStyleSheet(load_style_sheet())
    dlg.show()
    app.exec_()
Beispiel #2
0
    def __init__(self, name=None, prefix=None):
        """Widget to build an item for the environments list."""
        super(ListItemEnv, self).__init__()

        self._selected = False
        self._name = name
        self._prefix = prefix

        # Widgets
        self.button_options = ButtonEnvironmentOptions()
        self.button_name = ButtonEnvironmentName(name)
        self.label_icon = LabelEnvironmentIcon()
        self.movie = QMovie(SPINNER_GREEN_16_PATH)
        self.widget = WidgetEnvironment()
        self.widget.button_name = self.button_name
        self.widget.button_options = self.button_options

        # Widget setup
        self.button_name.setDefault(True)
        self.label_icon.setMovie(self.movie)
        self.widget.setFocusPolicy(Qt.NoFocus)
        self.button_name.setFocusPolicy(Qt.StrongFocus)
        self.button_options.setFocusPolicy(Qt.StrongFocus)

        # Layouts
        layout = QHBoxLayout()
        layout.addWidget(self.label_icon)
        layout.addWidget(self.button_name)
        layout.addWidget(self.button_options)
        layout.addStretch()

        self.widget.setLayout(layout)
        self.widget.setStyleSheet(load_style_sheet())
        self.setSizeHint(self.widget.sizeHint())
Beispiel #3
0
 def update_style_sheet(self):
     style_sheet = load_style_sheet()
     #        self.home_tab.update_style_sheet(style_sheet)
     self.environments_tab.update_style_sheet(style_sheet)
     #        self.community_tab.update_style_sheet(style_sheet)
     #        self.learning_tab.update_style_sheet(style_sheet)
     self.setStyleSheet(style_sheet)
Beispiel #4
0
def test_json_endpoint(dev=False):
    """Test production and development json content endpoints."""
    content = dev_endpoints() if dev else production_endpoints()
    widget = CommunityTab(content_urls=content)
    widget.update_style_sheet(load_style_sheet())
    widget.setup()
    return widget
Beispiel #5
0
def botchannels(qtbot, tmpfile):
    qtbot.api = AnacondaAPI()
    widget = DialogChannels()
    widget.update_style_sheet(load_style_sheet())

    temp_rc_content = """channels:
  - chdoig
  - sean"""

    with open(tmpfile, 'w') as f:
        f.write(temp_rc_content)

    # Mock conda config data
    config_data = {
        'config_sources': {
            tmpfile: {
                'channels': ['chdoig', 'sean']
            }
        }
    }
    api_info = {'conda_url': 'https://conda.beta.anaconda.org'}
    with qtbot.waitSignal(
        signal=widget.sig_setup_ready, timeout=5000, raising=True
    ):
        if random.randint(0, 1):
            widget.setup(None, config_data, None)
            widget.update_api(None, api_info, None)
        else:
            widget.update_api(None, api_info, None)
            widget.setup(None, config_data, None)

    widget.show()
    return qtbot, widget
Beispiel #6
0
    def update_style_sheet(self, style_sheet=None):
        if style_sheet is None:
            style_sheet = load_style_sheet()

        for item in self._items:
            item.update_style_sheet(style_sheet)
        self.setStyleSheet(style_sheet)
Beispiel #7
0
 def update_style_sheet(self, style_sheet=None):
     """Update custom CSS style sheet."""
     if style_sheet is None:
         self.style_sheet = load_style_sheet()
     else:
         self.style_sheet = style_sheet
     self.setStyleSheet(self.style_sheet)
Beispiel #8
0
def test_update_style_sheet(botchannels):
    qtbot, widget = botchannels
    widget.style_sheet = None
    widget.update_style_sheet(load_style_sheet())
    assert widget.style_sheet
    widget.style_sheet = None
    widget.update_style_sheet()
    assert widget.style_sheet
Beispiel #9
0
    def update_style_sheet(self, style_sheet=None):
        if style_sheet is None:
            self.style_sheet = load_style_sheet()
        else:
            self.style_sheet = style_sheet

        self.setStyleSheet(self.style_sheet)
        self.list.update_style_sheet(self.style_sheet)
Beispiel #10
0
    def update_style_sheet(self, style_sheet=None):
        """Update custom CSS stylesheet."""
        if style_sheet:
            self.style_sheet = style_sheet
        else:
            self.style_sheet = load_style_sheet()

        self.menu_options.setStyleSheet(self.style_sheet)
        self.menu_versions.setStyleSheet(self.style_sheet)
Beispiel #11
0
def local_test():  # pragma: no cover
    """Run loca tests."""
    from anaconda_navigator.utils.qthelpers import qapplication

    app = qapplication()
    widget = PasswordEdit()
    widget.update_style_sheet(style_sheet=load_style_sheet())
    widget.show()
    app.exec_()
Beispiel #12
0
def local_test():  # pragma: no cover
    """Run local test."""
    from anaconda_navigator.utils.qthelpers import qapplication

    app = qapplication()
    widget = AboutDialog(parent=None)
    widget.setStyleSheet(load_style_sheet())
    widget.show()
    app.exec_()
Beispiel #13
0
def local_test():  # pragma: no cover
    """Run local test."""
    from anaconda_navigator.utils.qthelpers import qapplication
    from anaconda_navigator.utils.styles import load_style_sheet

    app = qapplication()
    widget = EnvironmentsTab()
    widget.setStyleSheet(load_style_sheet())
    # widget.setup()
    widget.show()
    app.exec_()
Beispiel #14
0
def test():
    from anaconda_navigator.utils.qthelpers import qapplication
    app = qapplication()
    VIDEOS_URL = "http://content.continuum.io/api/videos"
    EVENTS_URL = "http://content.continuum.io/api/events"
    WEBINARS_URL = "http://content.continuum.io/api/webinars"
    w = CommunityTab(content_urls=[EVENTS_URL, VIDEOS_URL, WEBINARS_URL])
    w.update_style_sheet(load_style_sheet())
    w.setup_tab()
    w.showMaximized()
    sys.exit(app.exec_())
Beispiel #15
0
    def __init__(self, text=''):
        super(ListItemSeparator, self).__init__()

        self.widget = WidgetSeparator()
        self.widget.setStyleSheet(load_style_sheet())
        self.label = QLabel(text)

        layout = QHBoxLayout()
        layout.addWidget(self.label)

        self.widget.setLayout(layout)
        self.setSizeHint(self.widget.sizeHint())
Beispiel #16
0
def local_test():  # pragma: no cover
    """Run local tests."""
    from anaconda_navigator.utils.qthelpers import qapplication

    app = qapplication(test_time=3)
    widget = TabWidget()
    widget.addTab(QLabel('HELLO 1'), text='Home', icon=QIcon())
    widget.addTab(QLabel('HELLO 2'), text='Add', icon=QIcon())
    widget.add_link('link 1')
    widget.setStyleSheet(load_style_sheet())
    widget.showMaximized()
    widget.refresh()
    sys.exit(app.exec_())
Beispiel #17
0
    def update_style_sheet(self, style_sheet=None):
        """
        """
        if style_sheet is None:
            style_sheet = load_style_sheet()

        self.list_projects.setFrameStyle(QFrame.NoFrame)
        self.list_projects.setFrameShape(QFrame.NoFrame)
        self.list_projects.setStyleSheet(style_sheet)
        for i in range(self.list_projects.count()):
            item = self.list_projects.item(i)
            item.setSizeHint(QSize(60, 60))
        self.list_projects.repaint()
Beispiel #18
0
    def update_style_sheet(self, style_sheet=None):
        """Update custom css style sheets."""
        if style_sheet is None:
            self.style_sheet = load_style_sheet()
        else:
            self.style_sheet = style_sheet

        self.setStyleSheet(self.style_sheet)
        self.setMinimumWidth(SASS_VARIABLES.WIDGET_CHANNEL_DIALOG_WIDTH)

        try:
            self.list.update_style_sheet(style_sheet)
        except Exception:
            pass
Beispiel #19
0
def local_test():  # pragma: no cover
    """Run local test."""
    from anaconda_navigator.utils.qthelpers import qapplication
    from anaconda_navigator.utils.styles import load_style_sheet

    app = qapplication()
    api = AnacondaAPI()
    widget = DialogChannels(None)
    widget.update_style_sheet(load_style_sheet())
    widget.show()
    worker = api.conda_config_sources()
    worker_2 = api.api_urls()
    worker.sig_chain_finished.connect(widget.setup)
    worker_2.sig_chain_finished.connect(widget.update_api)
    sys.exit(app.exec_())
Beispiel #20
0
    def update_style_sheet(self, style_sheet=None):
        """
        """
        if style_sheet is None:
            style_sheet = load_style_sheet()

        for item in self._items:
            try:
                item_widget = self.itemWidget(item)
                item_widget.setStyleSheet(style_sheet)
                item.setSizeHint(item_widget.sizeHint())
            except Exception:
                # This error is just in case the C++ object has been
                # deleted and it is not crucial to log.
                pass
        self.update()
        self.repaint()
Beispiel #21
0
    def update_style_sheet(self, style_sheet=None):
        """Update custom CSS style sheet."""
        if style_sheet is None:
            self.style_sheet = load_style_sheet()
        else:
            self.style_sheet = style_sheet

        for item in self._items:
            try:
                item_widget = self.itemWidget(item)
                item_widget.setStyleSheet(self.style_sheet)
                item.text_channel.menu.setStyleSheet(self.style_sheet)
                item.setSizeHint(item.widget_size())
            except Exception:  # pragma: no cover
                pass
                # This error is just in case the C++ object has been
                # deleted and it is not crucial to log.
        self.update()
        self.repaint()
Beispiel #22
0
    def update_style_sheet(self, style_sheet=None):
        if style_sheet is None:
            style_sheet = load_style_sheet()

        self.setStyleSheet(style_sheet)
        self.menu_list.setStyleSheet(style_sheet)
        self.list_environments.setFrameStyle(QFrame.NoFrame)
        self.list_environments.setFrameShape(QFrame.NoFrame)
        self.packages_widget.table.setFrameStyle(QFrame.NoFrame)
        self.packages_widget.table.setFrameShape(QFrame.NoFrame)
        self.packages_widget.layout().setContentsMargins(0, 0, 0, 0)

        size = QSize(16, 16)

        palette = {
            'icon.action.not_installed': QIcon(images.CONDA_MANAGER_NOT_INSTALLED).pixmap(size),
            'icon.action.installed': QIcon(images.CONDA_MANAGER_INSTALLED).pixmap(size),
            'icon.action.remove': QIcon(images.CONDA_MANAGER_REMOVE).pixmap(size),
            'icon.action.add': QIcon(images.CONDA_MANAGER_ADD).pixmap(size),
            'icon.action.upgrade': QIcon(images.CONDA_MANAGER_UPGRADE).pixmap(size),
            'icon.action.downgrade': QIcon(images.CONDA_MANAGER_DOWNGRADE).pixmap(size),
            'icon.upgrade.arrow': QIcon(images.CONDA_MANAGER_UPGRADE_ARROW).pixmap(size),
            'background.remove': QColor(0, 0, 0, 0),
            'background.install': QColor(0, 0, 0, 0),
            'background.upgrade': QColor(0, 0, 0, 0),
            'background.downgrade': QColor(0, 0, 0, 0),
            'foreground.not.installed': QColor("#666"),
            'foreground.upgrade': QColor("#0071a0"),
            }

        self.packages_widget.update_style_sheet(
            style_sheet=style_sheet,
            extra_dialogs={'cancel_dialog': ClosePackageManagerDialog,
                           'apply_actions_dialog': ActionsDialog,
                           'message_box_error': MessageBoxError,
                           },
            palette=palette,
            )
Beispiel #23
0
    def update_style_sheet(self, style_sheet=None):
        """Update custom CSS style sheet."""
        if self.style_sheet:
            self.style_sheet = style_sheet
        else:
            self.style_sheet = load_style_sheet()

        self.setStyleSheet(self.style_sheet)

        for item in self._items:
            try:
                item_widget = self.itemWidget(item)
                item_widget.setStyleSheet(self.style_sheet)
                item.update_style_sheet(self.style_sheet)
                item.setSizeHint(item.widget_size())
            except Exception as e:
                print(e)
                # This error is just in case the C++ object has been deleted
                # and it is not crucial to log.
                pass

        self.update()
        self.repaint()
Beispiel #24
0
    def __init__(self, name=None, prefix=None):
        """Widget to build an item for the environments list."""
        super(ListItemEnv, self).__init__()

        self._selected = False
        self._name = name
        self._prefix = prefix

        # Widgets
        self.button_options = ButtonEnvironmentOptions()
        self.button_name = ButtonEnvironmentName(name)
        self.frame_icon = FrameEnvironmentIcon()
        self.widget = WidgetEnvironment()
        self.widget.button_name = self.button_name
        self.widget.button_options = self.button_options
        self.spinner = NavigatorSpinner(parent=self.widget, total_width=20)

        # Widget setup
        self.button_name.setDefault(True)
        self.widget.setFocusPolicy(Qt.NoFocus)
        self.button_name.setFocusPolicy(Qt.StrongFocus)
        self.button_options.setFocusPolicy(Qt.StrongFocus)
        self.button_name.setToolTip(prefix if prefix else '')
        lay = QHBoxLayout()
        lay.addWidget(self.spinner)
        self.frame_icon.setLayout(lay)

        # Layouts
        layout = QHBoxLayout()
        layout.addWidget(self.frame_icon)
        layout.addWidget(self.button_name)
        layout.addWidget(self.button_options)
        layout.addStretch()

        self.widget.setLayout(layout)
        self.widget.setStyleSheet(load_style_sheet())
        self.setSizeHint(self.widget.sizeHint())
Beispiel #25
0
 def update_style_sheet(self, style_sheet=None):
     """Update custom css style sheets."""
     if style_sheet is None:
         style_sheet = load_style_sheet()
     self.setMinimumWidth(400)
     self.setStyleSheet(style_sheet)
Beispiel #26
0
 def update_style_sheet(self, style_sheet=None):
     if style_sheet is None:
         style_sheet = load_style_sheet()
     self.menu_options.setStyleSheet(style_sheet)
     self.menu_versions.setStyleSheet(style_sheet)
Beispiel #27
0
 def update_style_sheet(self, style_sheet=None):
     if style_sheet is None:
         style_sheet = load_style_sheet()
     self.list_applications.update_style_sheet(style_sheet=style_sheet)
     self.setStyleSheet(style_sheet)
Beispiel #28
0
 def update_style_sheet(self, style_sheet=None):
     """Update custom css style sheet."""
     if style_sheet is None:
         style_sheet = load_style_sheet()
     self.setStyleSheet(style_sheet)
Beispiel #29
0
 def update_style_sheet(self, style_sheet=None):
     if style_sheet is None:
         style_sheet = load_style_sheet()
     self.setStyleSheet(style_sheet)
Beispiel #30
0
    def __init__(
        self,
        name=None,
        display_name=None,
        description=None,
        command=None,
        versions=None,
        image_path=None,
        prefix=None,
        needs_license=False,
        non_conda=False,
    ):
        """Item with custom widget for the applications list."""
        super(ListItemApplication, self).__init__()

        self.api = AnacondaAPI()
        self.prefix = prefix
        self.name = name
        self.display_name = display_name if display_name else name
        self.url = ''
        self.expired = False
        self.needs_license = needs_license
        self.description = description
        self.command = command
        self.versions = versions
        self.image_path = image_path if image_path else ANACONDA_ICON_256_PATH
        self.style_sheet = None
        self.timeout = 2000
        self.non_conda = non_conda
        self._vscode_version_value = None

        # Widgets
        self.button_install = ButtonApplicationInstall("Install")  # or Try!
        self.button_launch = ButtonApplicationLaunch("Launch")
        self.button_options = ButtonApplicationOptions()
        self.label_license = LabelApplicationLicense('')
        self.button_license = ButtonApplicationLicense('')
        self.label_icon = LabelApplicationIcon()
        self.label_name = LabelApplicationName(self.display_name)
        self.label_description = LabelApplicationDescription(self.description)
        self.button_version = ButtonApplicationVersion(
            to_text_string(self.version))
        self.menu_options = QMenu('Application options')
        self.menu_versions = QMenu('Install specific version')
        self.pixmap = QPixmap(self.image_path)
        self.timer = QTimer()
        self.widget = WidgetApplication()
        self.frame_spinner = FrameApplicationSpinner()
        self.spinner = NavigatorSpinner(self.widget, total_width=16)
        lay = QHBoxLayout()
        lay.addWidget(self.spinner)
        self.frame_spinner.setLayout(lay)

        # Widget setup
        self.button_version.setFocusPolicy(Qt.NoFocus)
        self.button_version.setEnabled(True)
        self.label_description.setAlignment(Qt.AlignCenter)
        self.timer.setInterval(self.timeout)
        self.timer.setSingleShot(True)
        self.label_icon.setPixmap(self.pixmap)
        self.label_icon.setScaledContents(True)  # important on High DPI!
        self.label_icon.setMaximumWidth(self.ICON_SIZE)
        self.label_icon.setMaximumHeight(self.ICON_SIZE)
        self.label_icon.setAlignment(Qt.AlignCenter)
        self.label_name.setAlignment(Qt.AlignCenter)
        self.label_name.setWordWrap(True)
        self.label_description.setWordWrap(True)
        self.label_description.setAlignment(Qt.AlignTop | Qt.AlignHCenter)
        self.frame_spinner.setVisible(False)

        # Layouts
        layout_spinner = QHBoxLayout()
        layout_spinner.addWidget(self.button_version, 0, Qt.AlignCenter)
        layout_spinner.addWidget(self.frame_spinner, 0, Qt.AlignCenter)

        layout_license = QHBoxLayout()
        layout_license.addStretch()
        layout_license.addWidget(self.label_license, 0, Qt.AlignCenter)
        layout_license.addWidget(self.button_license, 0, Qt.AlignCenter)
        layout_license.addStretch()

        layout_main = QVBoxLayout()
        layout_main.addWidget(self.button_options, 0, Qt.AlignRight)
        layout_main.addWidget(self.label_icon, 0, Qt.AlignCenter)
        layout_main.addWidget(self.label_name, 0, Qt.AlignCenter)
        layout_main.addLayout(layout_spinner)
        layout_main.addLayout(layout_license)
        layout_main.addWidget(self.label_description, 0, Qt.AlignCenter)
        layout_main.addWidget(self.button_launch, 0, Qt.AlignCenter)
        layout_main.addWidget(self.button_install, 0, Qt.AlignCenter)

        self.widget.setLayout(layout_main)
        self.widget.setStyleSheet(load_style_sheet())
        self.setSizeHint(self.widget_size())
        # This might help with visual quirks on the home screen
        self.widget.setMinimumSize(self.widget_size())

        # Signals
        self.button_install.clicked.connect(self.install_application)
        self.button_launch.clicked.connect(self.launch_application)
        self.button_options.clicked.connect(self.actions_menu_requested)
        self.button_license.clicked.connect(self.launch_url)
        self.timer.timeout.connect(self._application_launched)

        # Setup
        self.update_status()