Ejemplo n.º 1
0
    def __init__(self, parent, i):
        QtGui.QWizardPage.__init__(self, parent)
        self._i = i

        # Create label for description
        self._text_label = QtGui.QLabel(self)
        self._text_label.setTextFormat(QtCore.Qt.RichText)
        self._text_label.setWordWrap(True)

        # Create label for image
        self._comicLabel = QtGui.QLabel(self)
        pm = QtGui.QPixmap()
        if 'logo' in self._image_filename:
            pm.load(
                os.path.join(pyzo.pyzoDir, 'resources', 'appicons',
                             self._image_filename))
        elif self._image_filename:
            pm.load(
                os.path.join(pyzo.pyzoDir, 'resources', 'images',
                             self._image_filename))
        self._comicLabel.setPixmap(pm)
        self._comicLabel.setAlignment(QtCore.Qt.AlignHCenter
                                      | QtCore.Qt.AlignVCenter)

        # Layout
        theLayout = QtGui.QVBoxLayout(self)
        self.setLayout(theLayout)
        #
        theLayout.addWidget(self._text_label)
        theLayout.addStretch()
        theLayout.addWidget(self._comicLabel)
        theLayout.addStretch()
Ejemplo n.º 2
0
    def __init__(self, parent):
        QtGui.QScrollArea.__init__(self, parent)

        # Init the scroll area
        self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
        self.setWidgetResizable(True)
        self.setFrameShape(QtGui.QFrame.NoFrame)

        # Create widget and a layout
        self._content = QtGui.QWidget(parent)
        self._formLayout = QtGui.QFormLayout(self._content)

        # Collect classes of widgets to instantiate
        classes = []
        for t in self.INFO_KEYS:
            className = 'ShellInfo_' + t.key
            cls = globals()[className]
            classes.append((t, cls))

        # Instantiate all classes
        self._shellInfoWidgets = {}
        for t, cls in classes:
            # Instantiate and store
            instance = cls(self._content)
            self._shellInfoWidgets[t.key] = instance
            # Create label
            label = QtGui.QLabel(t, self._content)
            label.setToolTip(t.tt)
            # Add to layout
            self._formLayout.addRow(label, instance)

        # Add delete button

        t = translate('shell', 'Delete ::: Delete this shell configuration')
        label = QtGui.QLabel('', self._content)
        instance = QtGui.QPushButton(pyzo.icons.cancel, t, self._content)
        instance.setToolTip(t.tt)
        instance.setAutoDefault(False)
        instance.clicked.connect(self.parent().parent().onTabClose)
        deleteLayout = QtGui.QHBoxLayout()
        deleteLayout.addWidget(instance, 0)
        deleteLayout.addStretch(1)
        # Add to layout
        self._formLayout.addRow(label, deleteLayout)

        # Apply layout
        self._formLayout.setSpacing(15)
        self._content.setLayout(self._formLayout)
        self.setWidget(self._content)
Ejemplo n.º 3
0
    def __init__(self, parent=None):
        QtGui.QDialog.__init__(self, parent)
        self.setWindowTitle('Install a conda env?')
        self.setModal(True)

        text = 'Pyzo is only an editor. To execute code, you need a Python environment.\n\n'
        text += 'Do you want Pyzo to install a Python environment (miniconda)?\n'
        text += 'If not, you must arrange for a Python interpreter yourself'
        if not sys.platform.startswith('win'):
            text += ' or use the system Python'
        text += '.'
        text += '\n(You can always launch the installer from the shell menu.)'

        self._label = QtGui.QLabel(text, self)
        self._no = QtGui.QPushButton("No thanks (dont ask again)")
        self._yes = QtGui.QPushButton("Yes, please install Python!")

        self._no.clicked.connect(self.reject)
        self._yes.clicked.connect(self.accept)

        vbox = QtGui.QVBoxLayout(self)
        hbox = QtGui.QHBoxLayout()
        self.setLayout(vbox)
        vbox.addWidget(self._label, 1)
        vbox.addLayout(hbox, 0)
        hbox.addWidget(self._no, 2)
        hbox.addWidget(self._yes, 2)

        self._yes.setDefault(1)
Ejemplo n.º 4
0
    def __init__(self, parent, distro=None):
        QtGui.QWidget.__init__(self, parent)
        self.setMinimumSize(360, 256)  # Ensure title fits nicely

        # Create label widget and costumize
        self._label = QtGui.QLabel(self)
        self._label.setTextFormat(QtCore.Qt.RichText)
        self._label.setOpenExternalLinks(True)
        self._label.setWordWrap(True)
        self._label.setMargin(20)

        # Set font size (absolute value)
        font = self._label.font()
        font.setPointSize(11)  #(font.pointSize()+1)
        self._label.setFont(font)

        # Build
        distrotext = ''
        if distro:
            distrotext = '<br />brought to you by %s.' % distro
        text = splash_text.format(distro=distrotext, version=pyzo.__version__)

        # Set text
        self._label.setText(text)

        layout = QtGui.QVBoxLayout(self)
        self.setLayout(layout)
        layout.addStretch(1)
        layout.addWidget(self._label, 0)
        layout.addStretch(1)
Ejemplo n.º 5
0
    def __init__(self, parent, i):
        BasePyzoWizardPage.__init__(self, parent, i)

        # Create label and checkbox
        t1 = translate('wizard',
                       "This wizard can be opened using 'Help > Pyzo wizard'")
        t2 = translate('wizard', "Show this wizard on startup")
        self._label_info = QtGui.QLabel(t1, self)
        #self._check_show = QtGui.QCheckBox(t2, self)
        #self._check_show.stateChanged.connect(self._setNewUser)

        # Create language switcher
        self._langLabel = QtGui.QLabel(translate('wizard', "Select language"),
                                       self)
        #
        self._langBox = QtGui.QComboBox(self)
        self._langBox.setEditable(False)
        # Fill
        index, theIndex = -1, -1
        cur = pyzo.config.settings.language
        for lang in sorted(LANGUAGES):
            index += 1
            self._langBox.addItem(lang)
            if lang == LANGUAGE_SYNONYMS.get(cur, cur):
                theIndex = index
        # Set current index
        if theIndex >= 0:
            self._langBox.setCurrentIndex(theIndex)
        # Bind signal
        self._langBox.activated.connect(self.onLanguageChange)

        # Init check state
        #if pyzo.config.state.newUser:
        #    self._check_show.setCheckState(QtCore.Qt.Checked)

        # Create sublayout
        layout = QtGui.QHBoxLayout()
        layout.addWidget(self._langLabel, 0)
        layout.addWidget(self._langBox, 0)
        layout.addStretch(2)
        self.layout().addLayout(layout)

        # Add to layout
        self.layout().addSpacing(10)
        self.layout().addWidget(self._label_info)
Ejemplo n.º 6
0
    def __init__(self, parent=None):
        QtGui.QDialog.__init__(self, parent)
        self.setWindowTitle('Install miniconda')
        self.setModal(True)
        self.resize(500, 500)

        text = translate(
            'bootstrapconda',
            'This will download and install miniconda on your computer.')

        self._label = QtGui.QLabel(text, self)

        self._scipystack = QtGui.QCheckBox(
            translate('bootstrapconda', 'Also install scientific packages',
                      self))
        self._scipystack.setChecked(True)
        self._path = QtGui.QLineEdit(default_conda_dir, self)
        self._progress = QtGui.QProgressBar(self)
        self._outputLine = QtGui.QLabel(self)
        self._output = QtGui.QPlainTextEdit(self)
        self._output.setReadOnly(True)
        self._button = QtGui.QPushButton('Install', self)

        self._outputLine.setSizePolicy(QtGui.QSizePolicy.Ignored,
                                       QtGui.QSizePolicy.Fixed)

        vbox = QtGui.QVBoxLayout(self)
        self.setLayout(vbox)
        vbox.addWidget(self._label, 0)
        vbox.addWidget(self._path, 0)
        vbox.addWidget(self._scipystack, 0)
        vbox.addWidget(self._progress, 0)
        vbox.addWidget(self._outputLine, 0)
        vbox.addWidget(self._output, 1)
        vbox.addWidget(self._button, 0)

        self._button.clicked.connect(self.go)

        self.addOutput(
            translate('bootstrapconda', 'Waiting to start installation.\n'))
        self._progress.setVisible(False)

        self.lineFromStdOut.connect(self.setStatus)
Ejemplo n.º 7
0
 def __init__(self, parent):
     QtGui.QDialog.__init__(self, parent)
     self.setWindowTitle(pyzo.translate("menu dialog", "About Pyzo"))
     self.resize(600,500)
     
     # Layout
     layout = QtGui.QVBoxLayout(self)
     self.setLayout(layout)
     
     # Create image and title
     im = QtGui.QPixmap( os.path.join(pyzo.pyzoDir, 
                         'resources', 'appicons', 'pyzologo64.png') )
     imlabel = QtGui.QLabel(self)
     imlabel.setPixmap(im)
     textlabel = QtGui.QLabel(self)
     textlabel.setText('<h3>Pyzo: the Interactive Editor for Python</h3>')
     #
     titleLayout = QtGui.QHBoxLayout()
     titleLayout.addWidget(imlabel, 0)
     titleLayout.addWidget(textlabel, 1)
     #
     layout.addLayout(titleLayout, 0)
     
     # Create tab bar
     self._tabs = QtGui.QTabWidget(self)
     self._tabs.setDocumentMode(True)
     layout.addWidget(self._tabs, 1)
     
     # Create button box
     self._butBox = QtGui.QDialogButtonBox(self)
     self._butBox.setOrientation(QtCore.Qt.Horizontal)
     self._butBox.setStandardButtons(self._butBox.Close)
     layout.addWidget(self._butBox, 0)
     
     # Signals
     self._butBox.rejected.connect(self.close)
     
     # Create tabs
     self.createGeneralTab()
     self.createContributorsTab()
     self.createLicenseTab()
Ejemplo n.º 8
0
    def __init__(self, parent):
        super().__init__(parent)

        self._label = QtGui.QLabel('hello world')
        self._label.setTextFormat(QtCore.Qt.RichText)
        self._label.setWordWrap(True)
        # self._label.setOpenExternalLinks(True)
        self._label.linkActivated.connect(self.handle_link)
        font = self._label.font()
        font.setPointSize(font.pointSize() + 1)
        self._label.setFont(font)

        layout = QtGui.QVBoxLayout()
        self.setLayout(layout)
        layout.addWidget(self._label, 1)
Ejemplo n.º 9
0
    def __init__(self, parent=None, collection_filename=None):
        """
            Initializes an assistance instance.
            When collection_file is none, it is determined from the
            appDataDir.
        """
        from pyzo.util.qt import QtHelp
        super().__init__(parent)
        self.setWindowTitle('Help')
        pyzoDir, appDataDir = getResourceDirs()
        if collection_filename is None:
            # Collection file is stored in pyzo data dir:
            collection_filename = os.path.join(appDataDir, 'tools', 'docs.qhc')
        self._engine = QtHelp.QHelpEngine(collection_filename)

        # Important, call setup data to load the files:
        self._engine.setupData()

        # If no files are loaded, register at least the pyzo docs:
        if len(self._engine.registeredDocumentations()) == 0:
            doc_file = os.path.join(pyzoDir, 'resources', 'pyzo.qch')
            ok = self._engine.registerDocumentation(doc_file)

        # The main players:
        self._content = self._engine.contentWidget()
        self._index = self._engine.indexWidget()
        self._indexTab = QtGui.QWidget()
        il = QtGui.QVBoxLayout(self._indexTab)
        filter_text = QtGui.QLineEdit()
        il.addWidget(filter_text)
        il.addWidget(self._index)

        self._helpBrowser = HelpBrowser(self._engine)
        self._searchEngine = self._engine.searchEngine()
        self._settings = Settings(self._engine)

        self._progress = QtGui.QWidget()
        pl = QtGui.QHBoxLayout(self._progress)
        bar = QtGui.QProgressBar()
        bar.setMaximum(0)
        pl.addWidget(QtGui.QLabel('Indexing'))
        pl.addWidget(bar)

        self._searchResultWidget = self._searchEngine.resultWidget()
        self._searchQueryWidget = self._searchEngine.queryWidget()
        self._searchTab = QtGui.QWidget()
        search_layout = QtGui.QVBoxLayout(self._searchTab)
        search_layout.addWidget(self._searchQueryWidget)
        search_layout.addWidget(self._searchResultWidget)

        tab = QtGui.QTabWidget()
        tab.addTab(self._content, "Contents")
        tab.addTab(self._indexTab, "Index")
        tab.addTab(self._searchTab, "Search")
        tab.addTab(self._settings, "Settings")

        splitter = QtGui.QSplitter(self)
        splitter.addWidget(tab)
        splitter.addWidget(self._helpBrowser)

        layout = QtGui.QVBoxLayout(self)
        layout.addWidget(splitter)
        layout.addWidget(self._progress)

        # Connect clicks:
        self._content.linkActivated.connect(self._helpBrowser.setSource)
        self._index.linkActivated.connect(self._helpBrowser.setSource)
        self._searchEngine.searchingFinished.connect(self.onSearchFinish)
        self._searchEngine.indexingStarted.connect(self.onIndexingStarted)
        self._searchEngine.indexingFinished.connect(self.onIndexingFinished)
        filter_text.textChanged.connect(self._index.filterIndices)
        self._searchResultWidget.requestShowLink.connect(
            self._helpBrowser.setSource)
        self._searchQueryWidget.search.connect(self.goSearch)

        # Always re-index on startup:
        self._searchEngine.reindexDocumentation()

        self._search_term = None

        # Show initial page:
        # self.showHelpForTerm('welcome to pyzo')
        self._helpBrowser.setHtml(help_help)