def __init__(self, parent, i): QtWidgets.QWizardPage.__init__(self, parent) self._i = i # Create label for description self._text_label = QtWidgets.QLabel(self) self._text_label.setTextFormat(QtCore.Qt.RichText) self._text_label.setWordWrap(True) # Create label for image self._comicLabel = QtWidgets.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 = QtWidgets.QVBoxLayout(self) self.setLayout(theLayout) # theLayout.addWidget(self._text_label) theLayout.addStretch() theLayout.addWidget(self._comicLabel) theLayout.addStretch()
def __init__(self, parent=None): super().__init__(parent) # File encoding self.file_encoding = QtWidgets.QLabel(self) self.file_encoding.setFixedWidth(100) self.insertPermanentWidget(0, self.file_encoding, 0) # Cursor position self.cursor_pos = QtWidgets.QLabel(self) self.cursor_pos.setFixedWidth(190) self.insertPermanentWidget(1, self.cursor_pos, 0)
def __init__(self, parent): QtWidgets.QScrollArea.__init__(self, parent) # Init the scroll area self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) self.setWidgetResizable(True) self.setFrameShape(QtWidgets.QFrame.NoFrame) # Create widget and a layout self._content = QtWidgets.QWidget(parent) self._formLayout = QtWidgets.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 = QtWidgets.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 = QtWidgets.QLabel("", self._content) instance = QtWidgets.QPushButton(pyzo.icons.cancel, t, self._content) instance.setToolTip(t.tt) instance.setAutoDefault(False) instance.clicked.connect(self.parent().parent().onTabClose) deleteLayout = QtWidgets.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)
def __init__(self, parent=None): QtWidgets.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 = QtWidgets.QLabel(text, self) self._no = QtWidgets.QPushButton("No thanks (dont ask again)") self._yes = QtWidgets.QPushButton("Yes, please install Python!") self._no.clicked.connect(self.reject) self._yes.clicked.connect(self.accept) vbox = QtWidgets.QVBoxLayout(self) hbox = QtWidgets.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)
def __init__(self, name, other): super().__init__() self.widget = other layout = QtWidgets.QHBoxLayout() layout.addWidget( QtWidgets.QLabel(text=name.capitalize().strip() + " :")) layout.addWidget(other) self.setLayout(layout)
def __init__(self, parent=None): QtWidgets.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 = QtWidgets.QLabel(text, self) self._scipystack = QtWidgets.QCheckBox( translate("bootstrapconda", "Also install scientific packages"), self ) self._scipystack.setChecked(True) self._path = QtWidgets.QLineEdit(default_conda_dir, self) self._progress = QtWidgets.QProgressBar(self) self._outputLine = QtWidgets.QLabel(self) self._output = QtWidgets.QPlainTextEdit(self) self._output.setReadOnly(True) self._button = QtWidgets.QPushButton("Install", self) self._outputLine.setSizePolicy( QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.Fixed ) vbox = QtWidgets.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)
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 = QtWidgets.QLabel(t1, self) # self._check_show = QtWidgets.QCheckBox(t2, self) # self._check_show.stateChanged.connect(self._setNewUser) # Create language switcher self._langLabel = QtWidgets.QLabel(translate("wizard", "Select language"), self) # self._langBox = QtWidgets.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 = QtWidgets.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)
def __init__(self, parent): QtWidgets.QDialog.__init__(self, parent) self.setWindowTitle(pyzo.translate("menu dialog", "About Pyzo")) self.resize(600, 500) # Layout layout = QtWidgets.QVBoxLayout(self) self.setLayout(layout) # Create image and title im = QtGui.QPixmap( os.path.join(pyzo.pyzoDir, "resources", "appicons", "pyzologo64.png")) imlabel = QtWidgets.QLabel(self) imlabel.setPixmap(im) textlabel = QtWidgets.QLabel(self) textlabel.setText("<h3>Pyzo: the Interactive Editor for Python</h3>") # titleLayout = QtWidgets.QHBoxLayout() titleLayout.addWidget(imlabel, 0) titleLayout.addWidget(textlabel, 1) # layout.addLayout(titleLayout, 0) # Create tab bar self._tabs = QtWidgets.QTabWidget(self) self._tabs.setDocumentMode(True) layout.addWidget(self._tabs, 1) # Create button box self._butBox = QtWidgets.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()
def __init__(self, parent): super().__init__(parent) self._label = QtWidgets.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() + 2) self._label.setFont(font) layout = QtWidgets.QVBoxLayout() self.setLayout(layout) layout.addWidget(self._label, 1)
def __init__(self, parent, distro=None): QtWidgets.QWidget.__init__(self, parent) self.setMinimumSize(360, 256) # Ensure title fits nicely # Create label widget and costumize self._label = QtWidgets.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 text_title = translate( "splash", "This is <b>Pyzo</b><br />the Python IDE for scientific computing") text_version = translate("splash", "Version") text_os = translate( "splash", "Pyzo is open source software and freely available for everyone.") text = splash_text.format( version=pyzo.__version__, text_title=text_title, text_version=text_version, text_os=text_os, ) # Set text self._label.setText(text) layout = QtWidgets.QVBoxLayout(self) self.setLayout(layout) layout.addStretch(1) layout.addWidget(self._label, 0) layout.addStretch(1)
def __init__(self): super().__init__() from pyzo.qt import QtPrintSupport self.printer = QtPrintSupport.QPrinter( QtPrintSupport.QPrinter.HighResolution, ) # To allow pdf export with color self.printer.setColorMode(QtPrintSupport.QPrinter.Color) # Default settings self.show_line_number = True self._enable_syntax_highlighting = True # Set title self.setWindowTitle(translate("menu dialog", "Pdf Export")) # Set dialog size size = 1000, 600 offset = 0 size2 = size[0], size[1] + offset self.resize(*size2) # self.setMinimumSize(*size2) # Button to export to pdf self.validation_button = QtWidgets.QPushButton("Export") self.validation_button.clicked.connect(self._export_pdf) # Button to update the preview self.button_update_preview = QtWidgets.QPushButton( "Update preview", self) self.button_update_preview.clicked.connect(self._update_preview) # Previw widget self.preview = QtPrintSupport.QPrintPreviewWidget(self.printer) # Lines numbers option self.checkbox_line_number = QtWidgets.QCheckBox( "Print line number", self, checked=self.show_line_number) self.checkbox_line_number.stateChanged.connect( self._get_show_line_number) # Make of copy of the editor self.current_editor = pyzo.editors.getCurrentEditor() self.editor_name = self.current_editor.name self.editor_filename = self.current_editor.filename self.editor = pyzo.core.editor.PyzoEditor( pyzo.editors.getCurrentEditor().toPlainText()) # Zoom # The default zoom is the current zoom used by the editor self.original_zoom = pyzo.config.view.zoom self.zoom_slider = QtWidgets.QSlider(QtCore.Qt.Horizontal) self.zoom_slider.setMinimum(-10) # Maybe too much ? self.zoom_slider.setMaximum(10) self.zoom_slider.setTickInterval(1) self.zoom_selected = self.original_zoom self.zoom_slider.setValue(self.zoom_selected) self.zoom_value_label = QtWidgets.QLabel() self._zoom_value_changed() self.zoom_slider.valueChanged.connect(self._zoom_value_changed) # Option for syntax highlighting self.checkbox_syntax_highlighting = QtWidgets.QCheckBox( "Enable syntax highlighting", self, checked=self._enable_syntax_highlighting) self.checkbox_syntax_highlighting.stateChanged.connect( self._change_syntax_highlighting_option) self.combobox_file_name = QtWidgets.QComboBox(self) self.combobox_file_name.addItem("Do not print the file name", 0) self.combobox_file_name.addItem("Print with file name", 1) self.combobox_file_name.addItem( "Print with file name and absolute path", 2) self.combobox_file_name.setCurrentIndex(1) self.combobox_file_name.setToolTip( "The title at the top of the document") # Orientation self.combobox_orientation = QtWidgets.QComboBox(self) self.combobox_orientation.addItem("Portrait", 0) self.combobox_orientation.addItem("Landscape", 1) self.combobox_orientation.setToolTip("Orientation of the document") # Layout self.main_layout = QtWidgets.QHBoxLayout() self.setLayout(self.main_layout) self.preview.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) self.right_layout = QtWidgets.QVBoxLayout() self.option_layout = QtWidgets.QFormLayout() self.main_layout.addWidget(self.preview) self.main_layout.addLayout(self.right_layout) self.right_layout.addLayout(self.option_layout) self.option_layout.addRow(self.combobox_file_name) self.option_layout.addRow(self.checkbox_line_number) self.option_layout.addRow(self.checkbox_syntax_highlighting) self.option_layout.addRow(self.zoom_value_label, self.zoom_slider) # self.option_layout.addRow(self.combobox_orientation) # orientation appears to be broken self.bottom_layout = QtWidgets.QHBoxLayout() self.right_layout.addLayout(self.bottom_layout) self.bottom_layout.addStretch() self.bottom_layout.addWidget(self.button_update_preview) self.bottom_layout.addWidget(self.validation_button) self._update_preview()
def __init__(self, themes, *args, editor=None, **kwargs): super().__init__(*args, **kwargs) # dict of themes, a deep copy of pyzo.themes self.themes = themes # We store the key name separate so we can easier track renames self.cur_theme_key = "" # The current theme being changed self.cur_theme = None # If an editor is given, connect to it self.editor = editor if self.editor is not None: self.editor.tokenClicked.connect(self.focusOnStyle) self.styleChanged.connect(self.editor.setStyle) # Display editables style formats in a scroll area self.scrollArea = scrollArea = QtWidgets.QScrollArea() self.scrollArea.setWidgetResizable(True) formLayout = QtWidgets.QFormLayout() self.styleEdits = {} # Add one pair of label and StyleEdit per style element description # to the formLayout and connect the StyleEdit signals to the updatedStyle method for styleDesc in pyzo.codeeditor.CodeEditor.getStyleElementDescriptions( ): label = QtWidgets.QLabel(text=styleDesc.name, toolTip=styleDesc.description) label.setWordWrap(True) styleEdit = StyleEdit(styleDesc, toolTip=styleDesc.description) styleEdit.styleChanged.connect(self.updatedStyle) self.styleEdits[styleDesc.key] = styleEdit formLayout.addRow(label, styleEdit) wrapper = QtWidgets.QWidget() wrapper.setLayout(formLayout) wrapper.setMinimumWidth(650) scrollArea.setWidget(wrapper) # Basic theme I/O curThemeLbl = QtWidgets.QLabel(text="Themes :") self.curThemeCmb = curThemeCmb = QtWidgets.QComboBox() current_index = -1 for i, themeName in enumerate(self.themes.keys()): # We store the themeName in data in case the user renames one curThemeCmb.addItem(themeName, userData=themeName) if themeName == pyzo.config.settings.theme.lower(): current_index = i curThemeCmb.addItem("New...") loadLayout = QtWidgets.QHBoxLayout() loadLayout.addWidget(curThemeLbl) loadLayout.addWidget(curThemeCmb) self.saveBtn = saveBtn = QtWidgets.QPushButton(text="Save") saveBtn.clicked.connect(self.saveTheme) exitBtn = QtWidgets.QPushButton(text="Apply theme") exitBtn.clicked.connect(self.ok) exitLayout = QtWidgets.QHBoxLayout() exitLayout.addWidget(exitBtn) exitLayout.addWidget(saveBtn) # Packing it up mainLayout = QtWidgets.QVBoxLayout() mainLayout.addLayout(loadLayout) mainLayout.addWidget(scrollArea) mainLayout.addLayout(exitLayout) self.setLayout(mainLayout) curThemeCmb.currentIndexChanged.connect(self.indexChanged) curThemeCmb.currentTextChanged.connect(self.setTheme) # Init if current_index >= 0: curThemeCmb.setCurrentIndex(current_index) self.setTheme(pyzo.config.settings.theme)
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.qt import QtHelp super().__init__(parent) self.setWindowTitle("Help") pyzoDir, appDataDir, appConfigDir = 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") self._engine.registerDocumentation(doc_file) # The main players: self._content = self._engine.contentWidget() self._index = self._engine.indexWidget() self._indexTab = QtWidgets.QWidget() il = QtWidgets.QVBoxLayout(self._indexTab) filter_text = QtWidgets.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 = QtWidgets.QWidget() pl = QtWidgets.QHBoxLayout(self._progress) bar = QtWidgets.QProgressBar() bar.setMaximum(0) pl.addWidget(QtWidgets.QLabel("Indexing")) pl.addWidget(bar) self._searchResultWidget = self._searchEngine.resultWidget() self._searchQueryWidget = self._searchEngine.queryWidget() self._searchTab = QtWidgets.QWidget() search_layout = QtWidgets.QVBoxLayout(self._searchTab) search_layout.addWidget(self._searchQueryWidget) search_layout.addWidget(self._searchResultWidget) tab = QtWidgets.QTabWidget() tab.addTab(self._content, "Contents") tab.addTab(self._indexTab, "Index") tab.addTab(self._searchTab, "Search") tab.addTab(self._settings, "Settings") splitter = QtWidgets.QSplitter(self) splitter.addWidget(tab) splitter.addWidget(self._helpBrowser) layout = QtWidgets.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)
def __init__(self, parent): QtWidgets.QWidget.__init__(self, parent) # Make sure there is a configuration entry for this tool # The pyzo tool manager makes sure that there is an entry in # config.tools before the tool is instantiated. toolId = self.__class__.__name__.lower() self._config = pyzo.config.tools[toolId] if not hasattr(self._config, "hideTypes"): self._config.hideTypes = [] # <kludge 2> # configuring the typeTranslation dictionary if not hasattr(self._config, "typeTranslation"): # to prevent the exception to be raised, one could init to : # {"method": "function", "function": "function", "type": "type", "private": "private", "module": "module"} self._config.typeTranslation = {} # Defaults self._config.typeTranslation["method"] = "function" self._config.typeTranslation["builtin_function_or_method"] = "function" # <kludge 2> # Create tool button self._up = QtWidgets.QToolButton(self) style = QtWidgets.qApp.style() self._up.setIcon(style.standardIcon(style.SP_ArrowLeft)) self._up.setIconSize(QtCore.QSize(16, 16)) # Create "path" line edit self._line = QtWidgets.QLineEdit(self) self._line.setReadOnly(True) self._line.setStyleSheet("QLineEdit { background:#ddd; }") self._line.setFocusPolicy(QtCore.Qt.NoFocus) # Create options menu self._options = QtWidgets.QToolButton(self) self._options.setIcon(pyzo.icons.filter) self._options.setIconSize(QtCore.QSize(16, 16)) self._options.setPopupMode(self._options.InstantPopup) self._options.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon) # self._options._menu = QtWidgets.QMenu() self._options.setMenu(self._options._menu) self.onOptionsPress() # create menu now # Create tree self._tree = WorkspaceTree(self) # Create message for when tree is empty self._initText = QtWidgets.QLabel( pyzo.translate( "pyzoWorkspace", """Lists the variables in the current shell's namespace. Currently, there are none. Some of them may be hidden because of the filters you configured.""", ), self, ) self._initText.setVisible(False) self._initText.setWordWrap(True) # Set layout layout = QtWidgets.QHBoxLayout() layout.addWidget(self._up, 0) layout.addWidget(self._line, 1) layout.addWidget(self._options, 0) # mainLayout = QtWidgets.QVBoxLayout(self) mainLayout.addLayout(layout, 0) mainLayout.addWidget(self._initText, 1) mainLayout.addWidget(self._tree, 2) mainLayout.setSpacing(2) # set margins margin = pyzo.config.view.widgetMargin mainLayout.setContentsMargins(margin, margin, margin, margin) self.setLayout(mainLayout) # Bind events self._up.pressed.connect(self._tree._proxy.goUp) self._options.pressed.connect(self.onOptionsPress) self._options._menu.triggered.connect(self.onOptionMenuTiggered)