コード例 #1
0
    def detect(self):

        link = '<a href="http://miniconda.pyzo.org">miniconda</a>'
        self._the_exe = None
        configs = pyzo.config.shellConfigs2

        # Hide now?
        if configs and configs[0].exe:
            self._label.setText('Happy coding!')
            QtCore.QTimer.singleShot(1200, self.hide_this)
            return

        # Try to find an interpreter
        from pyzo.util.interpreters import get_interpreters
        interpreters = reversed(get_interpreters('2.4'))
        conda_interpreters = [i for i in interpreters if i.is_conda]
        conda_interpreters.sort(
            key=lambda x: len(x.path.replace('pyzo', 'pyzo' * 10)))

        # Always sleep for a bit, so show that we've refreshed
        time.sleep(0.05)

        if conda_interpreters and conda_interpreters[0].version > '3':
            self._the_exe = conda_interpreters[0].path
            text = """Pyzo detected a conda environment in:
                      <br />%s<br /><br />
                      You can <a href='usefound'>use&nbsp;this&nbsp;environment</a>
                      (recommended), or manually specify an interpreter
                      by setting the exe in the <a href='config'>shell&nbsp;config</a>.
                      <br /><br />Click one of the links above, or <a href='refresh'>refresh</a>.
                   """ % (self._the_exe)
        elif conda_interpreters:
            text = """Pyzo detected a conda environment,
                      but it is Python 2. We strongly recommend using Python 3 instead.
                      <br /><br />
                      If you installed %s in a non-default location,
                      or if you want to manually specify an interpreter,
                      set the exe in the <a href='config'>shell&nbsp;config</a>.
                      <br /><br />Click one of the links above, or <a href='refresh'>refresh</a>.
                   """ % link
        elif interpreters:
            text = """Pyzo detected a Python interpreter,
                      but for scientific programming we recommend %s.
                      If you want to manually specify the interpreter,
                      set the exe in the <a href='config'>shell&nbsp;config</a>.
                      <br /><br />Click one of the links above, or <a href='refresh'>refresh</a>.
                   """ % link
        else:
            text = """Pyzo did not detect any Python interpreters.
                      We recomment installing %s for scientific programming
                      (and click <a href='refresh'>refresh</a> when done).
                      <br /><br />
                      If you installed miniconda in a non-default location,
                      or if you want to manually specify the interpreter,
                      set the exe in the <a href='config'>shell&nbsp;config</a>.
                   """ % link

        link_style = 'font-weight: bold; color:#369; text-decoration:underline;'
        self._label.setText(text.replace('<a ', '<a style="%s" ' % link_style))
コード例 #2
0
ファイル: shellStack.py プロジェクト: snarkturne/pyzo
 def detect(self):
     
     link = '<a href="http://miniconda.pyzo.org">miniconda</a>'
     self._the_exe = None
     configs = pyzo.config.shellConfigs2
     
     # Hide now?
     if configs and configs[0].exe:
         self._label.setText('Happy coding!')
         QtCore.QTimer.singleShot(1200, self.hide_this)
         return
     
     # Try to find an interpreter
     from pyzo.util.interpreters import get_interpreters
     interpreters = reversed(get_interpreters('2.4'))
     conda_interpreters = [i for i in interpreters if i.is_conda]
     conda_interpreters.sort(key=lambda x:len(x.path.replace('pyzo', 'pyzo'*10)))
     
     # Always sleep for a bit, so show that we've refreshed
     time.sleep(0.05)
     
     if conda_interpreters and conda_interpreters[0].version > '3':
         self._the_exe = conda_interpreters[0].path
         text = """Pyzo detected a conda environment in:
                   <br />%s<br /><br />
                   You can <a href='usefound'>use&nbsp;this&nbsp;environment</a>
                   (recommended), or manually specify an interpreter
                   by setting the exe in the <a href='config'>shell&nbsp;config</a>.
                   <br /><br />Click one of the links above, or <a href='refresh'>refresh</a>.
                """ % (self._the_exe)
     elif conda_interpreters:
         text = """Pyzo detected a conda environment,
                   but it is Python 2. We strongly recommend using Python 3 instead.
                   <br /><br />
                   If you installed %s in a non-default location,
                   or if you want to manually specify an interpreter,
                   set the exe in the <a href='config'>shell&nbsp;config</a>.
                   <br /><br />Click one of the links above, or <a href='refresh'>refresh</a>.
                """ % link
     elif interpreters:
         text = """Pyzo detected a Python interpreter,
                   but for scientific programming we recommend %s.
                   If you want to manually specify the interpreter,
                   set the exe in the <a href='config'>shell&nbsp;config</a>.
                   <br /><br />Click one of the links above, or <a href='refresh'>refresh</a>.
                """ % link
     else:
         text = """Pyzo did not detect any Python interpreters.
                   We recomment installing %s for scientific programming
                   (and click <a href='refresh'>refresh</a> when done).
                   <br /><br />
                   If you installed miniconda in a non-default location,
                   or if you want to manually specify the interpreter,
                   set the exe in the <a href='config'>shell&nbsp;config</a>.
                """ % link
     
     link_style = 'font-weight: bold; color:#369; text-decoration:underline;'
     self._label.setText(text.replace('<a ', '<a style="%s" ' % link_style))
コード例 #3
0
ファイル: shellInfoDialog.py プロジェクト: ysalmon/pyzo
 def __init__(self, *args):
     QtWidgets.QDialog.__init__(self, *args)
     self.setModal(True)
     
     # Set title
     self.setWindowTitle(pyzo.translate('shell', 'Shell configurations'))
     # Create tab widget
     self._tabs = QtWidgets.QTabWidget(self)
     #self._tabs = CompactTabWidget(self, padding=(4,4,5,5))
     #self._tabs.setDocumentMode(False)
     self._tabs.setMovable(True)
     
     # Get known interpreters (sorted them by version)
     # Do this here so we only need to do it once ...
     from pyzo.util.interpreters import get_interpreters
     self.interpreters = list(reversed(get_interpreters('2.4')))
     
     # Introduce an entry if there's none
     if not pyzo.config.shellConfigs2:
         w = ShellInfoTab(self._tabs)
         self._tabs.addTab(w, '---')
         w.setInfo()
     
     # Fill tabs
     for item in pyzo.config.shellConfigs2:
         w = ShellInfoTab(self._tabs)
         self._tabs.addTab(w, '---')
         w.setInfo(item)
     
     # Enable making new tabs and closing tabs
     self._add = QtWidgets.QToolButton(self)
     self._tabs.setCornerWidget(self._add)
     self._add.clicked.connect(self.onAdd)
     self._add.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon)
     self._add.setIcon(pyzo.icons.add)
     self._add.setText(translate('shell', 'Add config'))
     #
     #self._tabs.setTabsClosable(True)
     self._tabs.tabCloseRequested.connect(self.onTabClose)
     
     # Create buttons
     cancelBut = QtWidgets.QPushButton("Cancel", self)
     okBut = QtWidgets.QPushButton("Done", self)
     cancelBut.clicked.connect(self.close)
     okBut.clicked.connect(self.applyAndClose)
     # Layout for buttons
     buttonLayout = QtWidgets.QHBoxLayout()
     buttonLayout.addStretch(1)
     buttonLayout.addWidget(cancelBut)
     buttonLayout.addSpacing(10)
     buttonLayout.addWidget(okBut)
     
     # Layout the widgets
     mainLayout = QtWidgets.QVBoxLayout(self)
     mainLayout.addSpacing(8)
     mainLayout.addWidget(self._tabs,0)
     mainLayout.addLayout(buttonLayout,0)
     self.setLayout(mainLayout)
     
     # Prevent resizing
     self.show()
     self.setMinimumSize(500, 400)
     self.resize(640, 500)
コード例 #4
0
ファイル: shellInfoDialog.py プロジェクト: operade/pyzo
    def __init__(self, *args):
        QtGui.QDialog.__init__(self, *args)
        self.setModal(True)

        # Set title
        self.setWindowTitle(pyzo.translate('shell', 'Shell configurations'))
        # Create tab widget
        self._tabs = QtGui.QTabWidget(self)
        #self._tabs = CompactTabWidget(self, padding=(4,4,5,5))
        #self._tabs.setDocumentMode(False)
        self._tabs.setMovable(True)

        # Get known interpreters (sorted them by version)
        # Do this here so we only need to do it once ...
        from pyzo.util.interpreters import get_interpreters
        self.interpreters = list(reversed(get_interpreters('2.4')))

        # Introduce an entry if there's none
        if not pyzo.config.shellConfigs2:
            w = ShellInfoTab(self._tabs)
            self._tabs.addTab(w, '---')
            w.setInfo()

        # Fill tabs
        for item in pyzo.config.shellConfigs2:
            w = ShellInfoTab(self._tabs)
            self._tabs.addTab(w, '---')
            w.setInfo(item)

        # Enable making new tabs and closing tabs
        self._add = QtGui.QToolButton(self)
        self._tabs.setCornerWidget(self._add)
        self._add.clicked.connect(self.onAdd)
        self._add.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon)
        self._add.setIcon(pyzo.icons.add)
        self._add.setText(translate('shell', 'Add config'))
        #
        #self._tabs.setTabsClosable(True)
        self._tabs.tabCloseRequested.connect(self.onTabClose)

        # Create buttons
        cancelBut = QtGui.QPushButton("Cancel", self)
        okBut = QtGui.QPushButton("Done", self)
        cancelBut.clicked.connect(self.close)
        okBut.clicked.connect(self.applyAndClose)
        # Layout for buttons
        buttonLayout = QtGui.QHBoxLayout()
        buttonLayout.addStretch(1)
        buttonLayout.addWidget(cancelBut)
        buttonLayout.addSpacing(10)
        buttonLayout.addWidget(okBut)

        # Layout the widgets
        mainLayout = QtGui.QVBoxLayout(self)
        mainLayout.addSpacing(8)
        mainLayout.addWidget(self._tabs, 0)
        mainLayout.addLayout(buttonLayout, 0)
        self.setLayout(mainLayout)

        # Prevent resizing
        self.show()
        self.setMinimumSize(500, 400)
        self.resize(640, 500)