Пример #1
0
class FirstSplash(DialogBase):
    """Startup splash to display the first time that Navigator runs."""
    def __init__(self, parent=None):
        """Startup splash to display the first time that Navigator runs."""
        super(FirstSplash, self).__init__(parent=parent)

        text = """
        Thanks for installing Anaconda!

        Anaconda Navigator helps you easily start important Python applications
        and manage the packages in your local Anaconda installation. It also
        connects you to online resources for learning and engaging with the
        Python, SciPy, and PyData community.

        To help us improve Anaconda Navigator, fix bugs, and make it even
        easier for everyone to use Python, we gather anonymized usage
        information, just like most web browsers and mobile apps.

        To opt out of this, please uncheck below (You can always change this
        setting in the Preferences menu).
        """
        # Variables
        self.config = CONF

        # Widgets
        self.button_ok = ButtonNormal('Ok')
        self.button_ok_dont_show = ButtonPrimary("Ok, and don't show again")
        self.checkbox_track = QCheckBox("Yes, I'd like to help improve "
                                        "Anaconda.")
        self.label_about = QLabel(text)
        self.widget_icon = QSvgWidget(ANACONDA_NAVIGATOR_LOGO)

        # Widget setup
        self.frame_title_bar.hide()
        self.widget_icon.setFixedSize(self.widget_icon.size_for_width(400))

        # Layouts
        layout_buttons = QHBoxLayout()
        layout_buttons.addStretch()
        layout_buttons.addWidget(self.button_ok)
        layout_buttons.addWidget(SpacerHorizontal())
        layout_buttons.addWidget(self.button_ok_dont_show)

        layout = QVBoxLayout()
        layout.addWidget(self.widget_icon, 0, Qt.AlignCenter)
        layout.addWidget(self.label_about)
        layout.addWidget(self.checkbox_track, 0, Qt.AlignCenter)
        layout.addWidget(SpacerVertical())
        layout.addWidget(SpacerVertical())
        layout.addLayout(layout_buttons)
        self.setLayout(layout)

        # Signals
        self.button_ok.clicked.connect(lambda: self.accept(show_startup=True))
        self.button_ok_dont_show.clicked.connect(
            lambda: self.accept(show_startup=False))

        self.setup()

    def setup(self):
        """Setup widget content."""
        provide_analytics = self.config.get('main', 'provide_analytics')
        self.checkbox_track.setChecked(provide_analytics)

    def accept(self, show_startup):
        """Override Qt method."""
        provide_analytics = self.checkbox_track.checkState() == Qt.Checked
        self.config.set('main', 'provide_analytics', provide_analytics)
        self.config.set('main', 'show_startup', show_startup)
        DialogBase.accept(self)

    def reject(self):
        """
        Override Qt method.

        Force user to select one of the two options bellow and disalow
        canceling the dialog (pressing escape)
        """
        pass
Пример #2
0
class AboutDialog(DialogBase):
    """About dialog."""
    GITHUB_URL = 'https://github.com/ContinuumIO/anaconda-issues/issues'

    # Url, action, description
    sig_url_clicked = Signal(object, object, object)

    def __init__(self, *args, **kwargs):
        """About dialog."""
        super(AboutDialog, self).__init__(*args, **kwargs)

        # Variables
        year = datetime.datetime.now().year
        text = """<b>Anaconda Navigator {version}</b><br>
            <br>Copyright &copy; 2016-{year} Anaconda, Inc.
            <p>Created by Anaconda
            <br>
            <p>For bug reports and feature requests, please visit our
            """.format(version=__version__, year=year)

        # Widgets
        self.widget_icon = QSvgWidget(images.ANACONDA_LOGO)
        self.label_about = QLabel(text)
        self.button_link = ButtonLink('Issue Tracker')
        self.button_label = ButtonLabel('on GitHub.')
        self.button_ok = ButtonNormal('Ok')

        # Widgets setup
        self.widget_icon.setFixedSize(self.widget_icon.size_for_width(100))
        self.button_ok.setMinimumWidth(70)
        self.button_ok.setDefault(True)
        self.setWindowTitle("About Anaconda Navigator")

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

        layout_content = QVBoxLayout()
        layout_content.addWidget(self.label_about, 0, Qt.AlignBottom)
        layout_content_h = QHBoxLayout()
        layout_content_h.addWidget(self.button_link, 0, Qt.AlignLeft)
        layout_content_h.addWidget(self.button_label, 0, Qt.AlignLeft)
        layout_content_h.addStretch(0)

        layout_content.addLayout(layout_content_h)
        layout_h.addLayout(layout_content)

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

        layout_main = QVBoxLayout()
        layout_main.addLayout(layout_h)
        layout_main.addWidget(SpacerVertical())
        layout_main.addWidget(SpacerVertical())
        layout_main.addLayout(layout_buttons)
        self.setLayout(layout_main)

        # Signals
        self.button_link.clicked.connect(lambda: self.sig_url_clicked.emit(
            self.GITHUB_URL, 'content', 'click'))
        self.button_ok.clicked.connect(self.accept)

        # Setup
        self.button_ok.setFocus()