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, engine): super().__init__() self._engine = engine layout = QtWidgets.QVBoxLayout(self) add_button = QtWidgets.QPushButton("Add") del_button = QtWidgets.QPushButton("Delete") self._view = QtWidgets.QListView() layout.addWidget(self._view) layout2 = QtWidgets.QHBoxLayout() layout2.addWidget(add_button) layout2.addWidget(del_button) layout.addLayout(layout2) self._model = QtCore.QStringListModel() self._view.setModel(self._model) self._model.setStringList(self._engine.registeredDocumentations()) add_button.clicked.connect(self.add_doc) del_button.clicked.connect(self.del_doc)
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 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): QtWidgets.QWidget.__init__(self, parent) # Create text field, checkbox, and button self._text = QtWidgets.QLineEdit(self) self._printBut = QtWidgets.QPushButton("Print", self) style = QtWidgets.qApp.style() self._backBut = QtWidgets.QToolButton(self) self._backBut.setIcon(style.standardIcon(style.SP_ArrowLeft)) self._backBut.setIconSize(QtCore.QSize(16, 16)) self._backBut.setPopupMode(self._backBut.DelayedPopup) self._backBut.setMenu( PyzoInteractiveHelpHistoryMenu("Backward menu", self, False)) self._forwBut = QtWidgets.QToolButton(self) self._forwBut.setIcon(style.standardIcon(style.SP_ArrowRight)) self._forwBut.setIconSize(QtCore.QSize(16, 16)) self._forwBut.setPopupMode(self._forwBut.DelayedPopup) self._forwBut.setMenu( PyzoInteractiveHelpHistoryMenu("Forward menu", self, True)) # Create options button self._options = QtWidgets.QToolButton(self) self._options.setIcon(pyzo.icons.wrench) self._options.setIconSize(QtCore.QSize(16, 16)) self._options.setPopupMode(self._options.InstantPopup) self._options.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon) # Create options menu self._options._menu = QtWidgets.QMenu() self._options.setMenu(self._options._menu) # Create browser self._browser = QtWidgets.QTextBrowser(self) self._browser_text = initText self._browser.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) self._browser.customContextMenuRequested.connect(self.showMenu) # Create two sizers self._sizer1 = QtWidgets.QVBoxLayout(self) self._sizer2 = QtWidgets.QHBoxLayout() # Put the elements together self._sizer2.addWidget(self._backBut, 1) self._sizer2.addWidget(self._forwBut, 2) self._sizer2.addWidget(self._text, 4) self._sizer2.addWidget(self._printBut, 0) self._sizer2.addWidget(self._options, 3) # self._sizer1.addLayout(self._sizer2, 0) self._sizer1.addWidget(self._browser, 1) # self._sizer1.setSpacing(2) # set margins margin = pyzo.config.view.widgetMargin self._sizer1.setContentsMargins(margin, margin, margin, margin) self.setLayout(self._sizer1) # Set config toolId = self.__class__.__name__.lower() self._config = config = pyzo.config.tools[toolId] # if not hasattr(config, "smartNewlines"): config.smartNewlines = True if not hasattr(config, "fontSize"): if sys.platform == "darwin": config.fontSize = 12 else: config.fontSize = 10 # Create callbacks self._text.returnPressed.connect(self.queryDoc) self._printBut.clicked.connect(self.printDoc) self._backBut.clicked.connect(self.goBack) self._forwBut.clicked.connect(self.goForward) # self._options.pressed.connect(self.onOptionsPress) self._options._menu.triggered.connect(self.onOptionMenuTiggered) # Start self._history = [] self._histindex = 0 self.setText() # Set default text self.onOptionsPress() # Fill menu
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, *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)
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)