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) # 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 # Create two sizers self._sizer1 = QtWidgets.QVBoxLayout(self) self._sizer2 = QtWidgets.QHBoxLayout() # Put the elements together self._sizer2.addWidget(self._text, 4) self._sizer2.addWidget(self._printBut, 0) self._sizer2.addWidget(self._options, 2) # self._sizer1.addLayout(self._sizer2, 0) self._sizer1.addWidget(self._browser, 1) # self._sizer1.setSpacing(2) self._sizer1.setContentsMargins(4, 4, 4, 4) 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._options.pressed.connect(self.onOptionsPress) self._options._menu.triggered.connect(self.onOptionMenuTiggered) # Start self.setText() # Set default text self.onOptionsPress() # Fill menu
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): 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 = [] # 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) # 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._tree, 1) mainLayout.setSpacing(2) mainLayout.setContentsMargins(4,4,4,4) 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)
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, 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, 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.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() self.createContributorsTab() self.createLicenseTab()
def __init__(self, parent, **kwargs): QtWidgets.QWidget.__init__(self, parent) self._left = LogoWidget(self) self._right = LabelWidget(self, **kwargs) # Layout layout = QtWidgets.QHBoxLayout(self) self.setLayout(layout) # layout.setContentsMargins(0,0,0,0) layout.setSpacing(25) layout.addStretch(1) layout.addWidget(self._left, 0) layout.addWidget(self._right, 0) layout.addStretch(1) # Change background of main window to create a splash-screen-efefct iconImage = "pyzologo256.png" iconImage = os.path.join(pyzo.pyzoDir, "resources", "appicons", iconImage) iconImage = iconImage.replace(os.path.sep, "/") # Fix for Windows self.setStyleSheet(STYLESHEET % iconImage)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.setWindowTitle("Color scheme") size = 1200, 800 offset = 0 size2 = size[0], size[1] + offset self.resize(*size2) # Make a deep copy themes = {} for name, theme in pyzo.themes.items(): theme = theme.copy() theme["data"] = theme["data"].copy() themes[name] = theme self.editor = FakeEditor() self.editColor = ThemeEditorWidget(themes=themes, editor=self.editor) self.editColor.done.connect(self.done) layout = QtWidgets.QHBoxLayout() layout.addWidget(self.editor, 1) layout.addWidget(self.editColor, 2) self.setLayout(layout)
def __init__(self, defaultStyle, *args, **kwargs): super().__init__(*args, **kwargs) #The styleKey is sent with the styleChanged signal for easy identification self.styleKey = defaultStyle.key self.layout = layout = QtWidgets.QHBoxLayout() # The setters are used when setting the style self.setters = {} #TODO: the use of StyleFormat._parts should be avoided # We use the StyleFormat._parts keys, to find the elements # Useful to edits, because the property may return a value # Even if they were not defined in the defaultFormat fmtParts = defaultStyle.defaultFormat._parts # Add the widgets corresponding to the fields if "fore" in fmtParts: self.__add_clrLineEdit("fore", "Foreground") if "back" in fmtParts: self.__add_clrLineEdit("back", "Background") if "bold" in fmtParts: self.__add_checkBox("bold", "Bold") if "italic" in fmtParts: self.__add_checkBox("italic", "Italic") if "underline" in fmtParts: self.__add_comboBox("underline", "Underline", "No", "Dotted", "Wave", "Full", "Yes") if "linestyle" in fmtParts: self.__add_comboBox("linestyle", "Linestyle", "Dashed", "Dotted", "Full") self.setLayout(layout) self.setSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Minimum)
def __init__(self): super().__init__() from pyzo.util.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 m = QtWidgets.QMessageBox(self) # 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", QtPrintSupport.QPrinter.Portrait) self.combobox_orientation.addItem("Landscape", QtPrintSupport.QPrinter.Landscape) 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) 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, 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] # Set config if not hasattr(self._config, "hideTypes"): self._config.hideTypes = [] # if not hasattr(self._config, "fontSizeTree"): if sys.platform == "darwin": self._config.fontSizeTree = 12 else: self._config.fontSizeTree = 10 if not hasattr(self._config, "fontSizeHelp"): if sys.platform == "darwin": self._config.fontSizeHelp = 12 else: self._config.fontSizeHelp = 10 # if not hasattr(self._config, "historyMaximum"): self._config.historyMaximum = 10 # if not hasattr(self._config, "historyFreeze"): # self._config.historyFreeze = 0 if not hasattr(self._config, "historyClearOnStartup"): self._config.historyClearOnStartup = 1 style = QtWidgets.qApp.style() # self.initText = "<p>{}</p>".format( "Click an item in the list for Help information.") # Create empty label self._empty = QtWidgets.QLabel(self) self._empty.setText("") # ----- Layout 1 ----- # Create Home tool button self._home = QtWidgets.QToolButton(self) self._home.setIcon(style.standardIcon(style.SP_ArrowUp)) self._home.setIconSize(QtCore.QSize(16, 16)) self._home.setToolTip("Home - return to the beginninig.") # Create Refresh tool button self._refresh = QtWidgets.QToolButton(self) self._refresh.setIcon(style.standardIcon(style.SP_BrowserReload)) self._refresh.setIconSize(QtCore.QSize(16, 16)) self._refresh.setToolTip("Reload the current command.") # Create Go back tool button self.back = QtWidgets.QToolButton(self) self.back.setIcon(style.standardIcon(style.SP_ArrowLeft)) self.back.setIconSize(QtCore.QSize(16, 16)) self.back.setToolTip("Go back to the previous command.") # 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 selection tool button self._selection = QtWidgets.QToolButton(self) self._selection.setIcon(pyzo.icons.layout) self._selection.setIconSize(QtCore.QSize(16, 16)) self._selection.setToolTip("Get selected objects in the document.") self._selection.setEnabled(False) # Create "insert_code" button self._insert_code = QtWidgets.QToolButton(self) self._insert_code.setIcon( style.standardIcon(style.SP_FileDialogDetailedView)) self._insert_code.setToolTip( "Insert code in the script at the cursor position") # ----- Layout 2 ----- # Create element_index combo box self._element_index = QtWidgets.QComboBox(self) self._element_index.setToolTip( "Set the argument for getByIndex method.") self._element_index.setEnabled(False) # Create element_names combo box self._element_names = QtWidgets.QComboBox(self) self._element_names.setToolTip("Get by name") self._element_names.setEnabled(False) # Create enumerate combo box self._enumerate_index = QtWidgets.QComboBox(self) self._enumerate_index.setToolTip( "Objects enumerated by createEnumeration method") self._enumerate_index.setEnabled(False) # Create history combo box self._history = QtWidgets.QComboBox(self) self._history.setToolTip("Show the command history") self._history.setEnabled(True) # Create options menu self._options = QtWidgets.QToolButton(self) self._options.setToolTip("Tool configuration.") 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) # main menu self._options._menu = pyzo.core.menu.Menu( self, "Main menu") # QtWidgets.QMenu() # submenus self._show_hide_menu = pyzo.core.menu.Menu(None, "Show/Hide") # self._font_size_menu = pyzo.core.menu.Menu(None, "Font size") self._font_size_tree_menu = pyzo.core.menu.Menu(None, "Workspace") self._font_size_help_menu = pyzo.core.menu.Menu(None, "Help") # self._history_menu = pyzo.core.menu.Menu(None, "History") # create menu self._options.setMenu(self._options._menu) self.onOptionsPress() # Show/hide Help button self._btn_toggle = QtWidgets.QToolButton(self) self._btn_toggle.setToolTip("Show/hide help") self._btn_toggle.setIcon(style.standardIcon(style.SP_DialogHelpButton)) self._btn_toggle.setIconSize(QtCore.QSize(16, 16)) self._btn_toggle.setCheckable(True) self._btn_toggle.setChecked(False) # ----- Layout 3 ----- # Create tree self._tree = PyUNOWorkspaceTree(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) # ----- Layout 4 ----- # Create description widget self._description = QtWidgets.QTextBrowser(self) self._description.setText(self.initText) # ----- Layout 5 ----- # Create counter self._desc_counter = QtWidgets.QLabel(self) self._desc_counter.setText("0") # Label self._desc_of = QtWidgets.QLabel(self) self._desc_of.setText(" of ") # Create all items counter self._desc_all_items = QtWidgets.QLabel(self) self._desc_all_items.setText("0") # self._search_line = QtWidgets.QLineEdit(self) self._search_line.setReadOnly(False) self._search_line.setToolTip("Search") self._search_line.setPlaceholderText("UNO API Search...") # self._match = QtWidgets.QCheckBox(self) self._match.setText("Match") self._match.setChecked(True) self._match.setToolTip("Match") # self._search = QtWidgets.QToolButton(self) self._search.setIconSize(QtCore.QSize(16, 16)) self._search.setText("Search") self._search.setToolTip("Search") # self._clear = QtWidgets.QToolButton(self) self._clear.setIconSize(QtCore.QSize(16, 16)) self._clear.setText("Clear") self._clear.setToolTip("Clear") # ------ Set layouts # Layout 1: Object and insert code layout layout_1 = QtWidgets.QHBoxLayout() layout_1.addWidget(self._home, 0) layout_1.addWidget(self._refresh, 0) layout_1.addWidget(self.back, 0) layout_1.addWidget(self._line, 1) layout_1.addWidget(self._selection, 0) layout_1.addWidget(self._insert_code, 0) # Layout 2: Display, arguments, history and option layout layout_2 = QtWidgets.QHBoxLayout() layout_2.addWidget(self._element_index, 0) layout_2.addWidget(self._element_names, 0) layout_2.addWidget(self._enumerate_index, 0) layout_2.addWidget(self._history, 1) layout_2.addWidget(self._options, 0) layout_2.addWidget(self._btn_toggle, 0) # Layout 3: Tree layout layout_3 = QtWidgets.QVBoxLayout() layout_3.addWidget(self._tree, 0) # Layout 5: Hidden help layout self._description_widget = QtWidgets.QWidget(self) self._description_widget.setVisible(False) layout_5 = QtWidgets.QVBoxLayout() layout_5.setSpacing(0) layout_5.setContentsMargins(0, 0, 0, 0) # Layout 6: Search layout layout_6 = QtWidgets.QHBoxLayout() layout_6.addWidget(self._desc_counter, 0) layout_6.addWidget(self._desc_of, 0) layout_6.addWidget(self._desc_all_items, 0) layout_6.addWidget(self._empty, 0) layout_6.addWidget(self._search_line, 0) layout_6.addWidget(self._empty, 0) layout_6.addWidget(self._match, 0) layout_6.addWidget(self._search, 0) layout_6.addWidget(self._clear, 0) # Layout 7: Help description layout layout_7 = QtWidgets.QVBoxLayout() layout_7.addWidget(self._description, 0) layout_5.addLayout(layout_7, 0) layout_5.addLayout(layout_6, 0) layout_7.setSpacing(0) layout_7.setContentsMargins(0, 0, 0, 0) # Main Layout mainLayout = QtWidgets.QVBoxLayout(self) mainLayout.addLayout(layout_1, 0) mainLayout.addLayout(layout_2, 0) mainLayout.addLayout(layout_3, 0) # add hidden widget mainLayout.addWidget(self._description_widget) self._description_widget.setLayout(layout_5) # set margins mainLayout.setContentsMargins(0, 0, 0, 0) self.setLayout(mainLayout) # ------ Bind events self._home.pressed.connect(self.onHomePress) self._refresh.pressed.connect(self.onRefreshPress) self.back.pressed.connect(self.onBackPress) # self._selection.pressed.connect(self.onCurrentSelectionPress) self._insert_code.pressed.connect(self.onInsertCodeInEditorPress) # self._element_names.activated[str].connect(self.onElementNamesPress) self._element_index.activated[str].connect(self.onElementIndexPress) self._enumerate_index.activated[str].connect( self.onEnumerateIndexPress) self._history.activated[str].connect(self.onHistoryPress) # self._options.pressed.connect(self.onOptionsPress) # self._show_hide_menu.triggered.connect(self.onShowHideMenuTiggered) self._font_size_help_menu.triggered.connect( self.onFontHelpOptionMenuTiggered) self._font_size_tree_menu.triggered.connect( self.onFontTreeOptionMenuTiggered) self._history_menu.triggered.connect(self.onHistoryOptionMenuTiggered) # self._btn_toggle.toggled.connect(self.onHelpTogglePress) # self._search.pressed.connect(self.onSearchPress) self._clear.pressed.connect(self.onClearHelpPress) # Create json result file createResultFile(), # Load History if self._config.historyClearOnStartup: #self._config.historyFreeze = 0 createHistoryFile() self.loadHistory()
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, 'showTypes'): self._config.showTypes = ['class', 'def', 'cell', 'todo'] if not hasattr(self._config, 'level'): self._config.level = 2 # Create icon for slider self._sliderIcon = QtWidgets.QToolButton(self) self._sliderIcon.setIcon(pyzo.icons.text_align_right) self._sliderIcon.setIconSize(QtCore.QSize(16, 16)) self._sliderIcon.setStyleSheet( "QToolButton { border: none; padding: 0px; }") # Create slider self._slider = QtWidgets.QSlider(QtCore.Qt.Horizontal, self) self._slider.setTickPosition(QtWidgets.QSlider.TicksBelow) self._slider.setSingleStep(1) self._slider.setPageStep(1) self._slider.setRange(1, 9) self._slider.setValue(self._config.level) self._slider.valueChanged.connect(self.updateStructure) # Create options button #self._options = QtWidgets.QPushButton(self) #self._options.setText('Options')) #self._options.setToolTip("What elements to show.") 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) # Create options menu self._options._menu = QtWidgets.QMenu() self._options.setMenu(self._options._menu) # Create tree widget self._tree = QtWidgets.QTreeWidget(self) self._tree.setHeaderHidden(True) self._tree.itemCollapsed.connect(self.updateStructure) # keep expanded self._tree.itemClicked.connect(self.onItemClick) # Create two sizers self._sizer1 = QtWidgets.QVBoxLayout(self) self._sizer2 = QtWidgets.QHBoxLayout() self._sizer1.setSpacing(2) self._sizer1.setContentsMargins(4, 4, 4, 4) # Set layout self._sizer1.addLayout(self._sizer2, 0) self._sizer1.addWidget(self._tree, 1) self._sizer2.addWidget(self._sliderIcon, 0) self._sizer2.addWidget(self._slider, 4) self._sizer2.addStretch(1) self._sizer2.addWidget(self._options, 2) # self.setLayout(self._sizer1) # Init current-file name self._currentEditorId = 0 # Bind to events pyzo.editors.currentChanged.connect(self.onEditorsCurrentChanged) pyzo.editors.parserDone.connect(self.updateStructure) self._options.pressed.connect(self.onOptionsPress) self._options._menu.triggered.connect(self.onOptionMenuTiggered) # Start # When the tool is loaded, the editorStack is already done loading # all previous files and selected the appropriate file. self.onOptionsPress() # Create menu now self.onEditorsCurrentChanged()
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, 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, *args): QtWidgets.QFrame.__init__(self, *args) self.setFocusPolicy(QtCore.Qt.ClickFocus) # init layout layout = QtWidgets.QHBoxLayout(self) layout.setSpacing(0) self.setLayout(layout) # Create some widgets first to realize a correct tab order self._hidebut = QtWidgets.QToolButton(self) self._findText = QtWidgets.QLineEdit(self) self._replaceText = QtWidgets.QLineEdit(self) if True: # Create sub layouts vsubLayout = QtWidgets.QVBoxLayout() vsubLayout.setSpacing(0) layout.addLayout(vsubLayout, 0) # Add button self._hidebut.setFont(QtGui.QFont('helvetica', 7)) self._hidebut.setToolTip( translate('search', 'Hide search widget (Escape)')) self._hidebut.setIcon(pyzo.icons.cancel) self._hidebut.setIconSize(QtCore.QSize(16, 16)) vsubLayout.addWidget(self._hidebut, 0) vsubLayout.addStretch(1) layout.addSpacing(10) if True: # Create sub layouts vsubLayout = QtWidgets.QVBoxLayout() hsubLayout = QtWidgets.QHBoxLayout() vsubLayout.setSpacing(0) hsubLayout.setSpacing(0) layout.addLayout(vsubLayout, 0) # Add find text self._findText.setToolTip(translate('search', 'Find pattern')) vsubLayout.addWidget(self._findText, 0) vsubLayout.addLayout(hsubLayout) # Add previous button self._findPrev = QtWidgets.QToolButton(self) t = translate( 'search', 'Previous ::: Find previous occurrence of the pattern.') self._findPrev.setText(t) self._findPrev.setToolTip(t.tt) hsubLayout.addWidget(self._findPrev, 0) hsubLayout.addStretch(1) # Add next button self._findNext = QtWidgets.QToolButton(self) t = translate('search', 'Next ::: Find next occurrence of the pattern.') self._findNext.setText(t) self._findNext.setToolTip(t.tt) #self._findNext.setDefault(True) # Not possible with tool buttons hsubLayout.addWidget(self._findNext, 0) layout.addSpacing(10) if True: # Create sub layouts vsubLayout = QtWidgets.QVBoxLayout() hsubLayout = QtWidgets.QHBoxLayout() vsubLayout.setSpacing(0) hsubLayout.setSpacing(0) layout.addLayout(vsubLayout, 0) # Add replace text self._replaceText.setToolTip(translate('search', 'Replace pattern')) vsubLayout.addWidget(self._replaceText, 0) vsubLayout.addLayout(hsubLayout) # Add replace-all button self._replaceAll = QtWidgets.QToolButton(self) t = translate( 'search', 'Repl. all ::: Replace all matches in current document.') self._replaceAll.setText(t) self._replaceAll.setToolTip(t.tt) hsubLayout.addWidget(self._replaceAll, 0) hsubLayout.addStretch(1) # Add replace button self._replace = QtWidgets.QToolButton(self) t = translate('search', 'Replace ::: Replace this match.') self._replace.setText(t) self._replace.setToolTip(t.tt) hsubLayout.addWidget(self._replace, 0) layout.addSpacing(10) if True: # Create sub layouts vsubLayout = QtWidgets.QVBoxLayout() vsubLayout.setSpacing(0) layout.addLayout(vsubLayout, 0) # Add match-case checkbox t = translate('search', 'Match case ::: Find words that match case.') self._caseCheck = QtWidgets.QCheckBox(t, self) self._caseCheck.setToolTip(t.tt) vsubLayout.addWidget(self._caseCheck, 0) # Add regexp checkbox t = translate('search', 'RegExp ::: Find using regular expressions.') self._regExp = QtWidgets.QCheckBox(t, self) self._regExp.setToolTip(t.tt) vsubLayout.addWidget(self._regExp, 0) if True: # Create sub layouts vsubLayout = QtWidgets.QVBoxLayout() vsubLayout.setSpacing(0) layout.addLayout(vsubLayout, 0) # Add whole-word checkbox t = translate('search', 'Whole words ::: Find only whole words.') self._wholeWord = QtWidgets.QCheckBox(t, self) self._wholeWord.setToolTip(t.tt) self._wholeWord.resize(60, 16) vsubLayout.addWidget(self._wholeWord, 0) # Add autohide dropbox t = translate( 'search', 'Auto hide ::: Hide search/replace when unused for 10 s.') self._autoHide = QtWidgets.QCheckBox(t, self) self._autoHide.setToolTip(t.tt) self._autoHide.resize(60, 16) vsubLayout.addWidget(self._autoHide, 0) layout.addStretch(1) # Set placeholder texts for lineEdit in [self._findText, self._replaceText]: if hasattr(lineEdit, 'setPlaceholderText'): lineEdit.setPlaceholderText(lineEdit.toolTip()) lineEdit.textChanged.connect(self.autoHideTimerReset) # Set focus policy for but in [ self._findPrev, self._findNext, self._replaceAll, self._replace, self._caseCheck, self._wholeWord, self._regExp ]: #but.setFocusPolicy(QtCore.Qt.ClickFocus) but.clicked.connect(self.autoHideTimerReset) # create timer objects self._timerBeginEnd = QtCore.QTimer(self) self._timerBeginEnd.setSingleShot(True) self._timerBeginEnd.timeout.connect(self.resetAppearance) # self._timerAutoHide = QtCore.QTimer(self) self._timerAutoHide.setSingleShot(False) self._timerAutoHide.setInterval(500) # ms self._timerAutoHide.timeout.connect(self.autoHideTimerCallback) self._timerAutoHide_t0 = time.time() self._timerAutoHide.start() # create callbacks self._findText.returnPressed.connect(self.findNext) self._hidebut.clicked.connect(self.hideMe) self._findNext.clicked.connect(self.findNext) self._findPrev.clicked.connect(self.findPrevious) self._replace.clicked.connect(self.replaceOne) self._replaceAll.clicked.connect(self.replaceAll) # self._regExp.stateChanged.connect(self.handleReplacePossible) # init case and regexp self._caseCheck.setChecked(bool(pyzo.config.state.find_matchCase)) self._regExp.setChecked(bool(pyzo.config.state.find_regExp)) self._wholeWord.setChecked(bool(pyzo.config.state.find_wholeWord)) self._autoHide.setChecked(bool(pyzo.config.state.find_autoHide)) # show or hide? if bool(pyzo.config.state.find_show): self.show() else: self.hide()
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. tool_id = self.__class__.__name__.lower() self._config = pyzo.config.tools[tool_id] if not hasattr(self._config, "fontSize"): if sys.platform == "darwin": self._config.fontSize = 12 else: self._config.fontSize = 10 # Style theme = pyzo.themes[pyzo.config.settings.theme.lower()]["data"] background_style = theme["editor.text"].split(",") background = background_style[1].split(":")[1] textcolor_style = theme["syntax.identifier"].split(",") textcolor = textcolor_style[0].split(":")[1] # Keep track of linter output self.output = "" # Folder for linter output file self.output_folder = os.path.join(pyzo.appDataDir, "tools", "pyzoLinter") self.process = None self.locale_codec = pyzo.QtCore.QTextCodec.codecForLocale() self.cur_dir_path = "" # Create button for parsing scope self._reload = QtWidgets.QToolButton(self) self._reload.setIcon(pyzo.icons.arrow_refresh) self._reload.setToolTip("Parse") # event self._reload.clicked.connect(self.start) # Create combo box Scope scope_list = ["Current document", "Current document directory"] self._scope = QtWidgets.QComboBox(self) self._scope.setToolTip("Get by index") self._scope.addItems(scope_list) # Create font options menu self._font_options = QtWidgets.QToolButton(self) self._font_options.setIcon(pyzo.icons.wrench) self._font_options.setIconSize(QtCore.QSize(16, 16)) self._font_options.setPopupMode(self._font_options.InstantPopup) self._font_options.setToolButtonStyle( QtCore.Qt.ToolButtonTextBesideIcon) self._font_options._menu = QtWidgets.QMenu() self._font_options.setMenu(self._font_options._menu) self.on_font_options_press() # create menu now # event self._font_options.pressed.connect(self.on_font_options_press) self._font_options._menu.triggered.connect( self.on_font_option_menu_tiggered) # Create button for opening output file in the editor self._open_file = QtWidgets.QToolButton(self) self._open_file.setIcon(pyzo.icons.page_white_text) self._open_file.setIconSize(QtCore.QSize(16, 16)) self._open_file.setStyleSheet( "QToolButton { border: none; padding: 0px; }") self._open_file.setToolTip("Open output file in the editor") # event self._open_file.clicked.connect(self.on_open_output_file) # Ratings label self._ratings = QtWidgets.QLabel(self) self._ratings.setText("") self._ratings.setAlignment(QtCore.Qt.AlignCenter) style_sheet = "QLabel{color: black;background-color: #FFFFE0;font : bold;}" self._ratings.setStyleSheet(style_sheet) # Create radio box All self._all = QtWidgets.QRadioButton(self) self._all.setText(ALL) self._all.setChecked(True) self._all.setToolTip(ALL) # Create radio box Convention self._convention = QtWidgets.QRadioButton(self) self._convention.setText(CONVENTION) self._convention.setToolTip(CONVENTION) # Create radio box Refactor self._refactor = QtWidgets.QRadioButton(self) self._refactor.setText(REFACTOR) self._refactor.setToolTip(REFACTOR) # Create radio box Warning self._warning = QtWidgets.QRadioButton(self) self._warning.setText(WARNING) self._warning.setToolTip(WARNING) # Create radio box Error self._error = QtWidgets.QRadioButton(self) self._error.setText(ERROR) self._error.setToolTip(ERROR) # Radio box event self._all.toggled.connect( lambda: self.on_radio_change_state(self._all)) self._convention.toggled.connect( lambda: self.on_radio_change_state(self._convention)) self._refactor.toggled.connect( lambda: self.on_radio_change_state(self._refactor)) self._warning.toggled.connect( lambda: self.on_radio_change_state(self._warning)) self._error.toggled.connect( lambda: self.on_radio_change_state(self._error)) # Create tree widget self._tree = QtWidgets.QTreeWidget(self) self._tree.setColumnCount(5) self._tree.setHeaderLabels( ["Description", "File", "Code", "Line", "Column"]) self._tree.setColumnWidth(0, 400) self._tree.setColumnWidth(1, 80) self._tree.setHeaderHidden(False) self._tree.setSortingEnabled(True) self._tree.sortItems(1, QtCore.Qt.AscendingOrder) self._tree.sortItems(2, QtCore.Qt.AscendingOrder) self._tree.setRootIsDecorated(False) # style # set widget stye background = self.get_theme_item(item="editor.text") textcolor = self.get_theme_item(item="syntax.identifier") style_keys = ["background-color", "color"] style_values = [background["back"], textcolor["fore"]] self.set_widget_style_sheet(self._tree, style_keys, style_values) # event self._tree.clicked.connect(self.on_item_clicked) # Create two sizers self._sizer1 = QtWidgets.QVBoxLayout(self) self._sizer2 = QtWidgets.QHBoxLayout() self._sizer4 = QtWidgets.QHBoxLayout() # self._sizer1.setSpacing(2) self._sizer1.setContentsMargins(0, 0, 0, 0) # Set layout self._sizer1.addLayout(self._sizer2, 0) self._sizer1.addLayout(self._sizer4, 0) self._sizer1.addWidget(self._tree, 1) # self._sizer2.addWidget(self._reload, 0) self._sizer2.addWidget(self._scope, 0) self._sizer2.addWidget(self._ratings, 0) self._sizer2.addWidget(self._font_options, 0) # self._sizer4.addWidget(self._all, 0) self._sizer4.addWidget(self._convention, 0) self._sizer4.addWidget(self._refactor, 0) self._sizer4.addWidget(self._warning, 0) self._sizer4.addWidget(self._error, 0) self._sizer4.addWidget(self._open_file, 0) # self.setLayout(self._sizer1)
def __init__(self, *args): QtWidgets.QDialog.__init__(self, *args) self.input = DIALOG_INPUT self.placeholders = """ Placeholders:\n %b \n Gets replaced by the selected text in the File Browser %d \n Gets replaced by the path to the directory of the active document %e \n Gets replaced by the name of the active document, including its extension %f \n Gets replaced by the local filepath to the active document %n \n Gets replaced by the name of the active document without its extension %s \n Gets replaced by the selected text in the active document """ # Set size size = 650, 190 offset = 0 size2 = size[0], size[1] + offset self.resize(*size2) self.setMaximumSize(*size2) self.setMinimumSize(*size2) self.item = "" note = "NOTE: It is your responsibility to prevent running hazardous commands" self._note_label = QtWidgets.QLabel(self) self._note_label.setText(note) layout_1 = QtWidgets.QHBoxLayout() layout_1.addWidget(self._note_label, 0) # Name self._name_label = QtWidgets.QLabel(self) self._name_label.setText("Name") self._name = QtWidgets.QLineEdit(self) self._name.setReadOnly(False) # Command self._command_label = QtWidgets.QLabel(self) self._command_label.setText("Command") self._command = QtWidgets.QLineEdit(self) self._command.setReadOnly(False) self._command.setToolTip(str(self.placeholders)) # Grid self.horizontalGroupBox = QtWidgets.QGroupBox() layout_grid = QtWidgets.QGridLayout() layout_grid.setColumnStretch(1, 2) layout_grid.addWidget(self._name_label, 0, 0) layout_grid.addWidget(self._name, 0, 1) layout_grid.addWidget(self._command_label, 1, 0) layout_grid.addWidget(self._command, 1, 1) self.horizontalGroupBox.setLayout(layout_grid) self.button_box = QtWidgets.QDialogButtonBox( QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel) self.button_box.accepted.connect(self.accept) self.button_box.rejected.connect(self.reject) layout_2 = QtWidgets.QHBoxLayout() layout_2.addWidget(self.button_box, 0) # Layouts mainLayout = QtWidgets.QVBoxLayout(self) mainLayout.addLayout(layout_1, 0) mainLayout.addWidget(self.horizontalGroupBox) mainLayout.addLayout(layout_2, 0) self.setLayout(mainLayout)
def __init__(self, parent): QtWidgets.QFrame.__init__(self, parent) # Init config toolId = self.__class__.__name__.lower() self._config = pyzo.config.tools[toolId] if not hasattr(self._config, 'zoomFactor'): self._config.zoomFactor = 1.0 if not hasattr(self._config, 'bookMarks'): self._config.bookMarks = [] for item in default_bookmarks: if item not in self._config.bookMarks: self._config.bookMarks.append(item) # Get style object (for icons) style = QtWidgets.QApplication.style() # Create some buttons self._back = QtWidgets.QToolButton(self) self._back.setIcon(style.standardIcon(style.SP_ArrowBack)) self._back.setIconSize(QtCore.QSize(16, 16)) # self._forward = QtWidgets.QToolButton(self) self._forward.setIcon(style.standardIcon(style.SP_ArrowForward)) self._forward.setIconSize(QtCore.QSize(16, 16)) # Create address bar #self._address = QtWidgets.QLineEdit(self) self._address = QtWidgets.QComboBox(self) self._address.setEditable(True) self._address.setInsertPolicy(self._address.NoInsert) # for a in self._config.bookMarks: self._address.addItem(a) self._address.setEditText('') # Create web view if imported_qtwebkit: self._view = QtWebKit.QWebView(self) else: self._view = WebView(self) # # self._view.setZoomFactor(self._config.zoomFactor) # settings = self._view.settings() # settings.setAttribute(settings.JavascriptEnabled, True) # settings.setAttribute(settings.PluginsEnabled, True) # Layout self._sizer1 = QtWidgets.QVBoxLayout(self) self._sizer2 = QtWidgets.QHBoxLayout() # self._sizer2.addWidget(self._back, 0) self._sizer2.addWidget(self._forward, 0) self._sizer2.addWidget(self._address, 1) # self._sizer1.addLayout(self._sizer2, 0) self._sizer1.addWidget(self._view, 1) # self._sizer1.setSpacing(2) self.setLayout(self._sizer1) # Bind signals self._back.clicked.connect(self.onBack) self._forward.clicked.connect(self.onForward) self._address.lineEdit().returnPressed.connect(self.go) self._address.activated.connect(self.go) self._view.loadFinished.connect(self.onLoadEnd) self._view.loadStarted.connect(self.onLoadStart) # Start self._view.show() self.go('http://docs.python.org')
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, 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, "showTypes"): self._config.showTypes = ["class", "def", "cell", "todo"] if not hasattr(self._config, "level"): self._config.level = 2 # Keep track of clicks so we can "go back" self._nav = {} # editor-id -> Navigation object # Keep track of sorting order self._sort_order = None # Create buttons for navigation self._navbut_back = QtWidgets.QToolButton(self) self._navbut_back.setIcon(pyzo.icons.arrow_left) self._navbut_back.setIconSize(QtCore.QSize(16, 16)) self._navbut_back.setStyleSheet( "QToolButton { border: none; padding: 0px; }") self._navbut_back.clicked.connect(self.onNavBack) # self._navbut_forward = QtWidgets.QToolButton(self) self._navbut_forward.setIcon(pyzo.icons.arrow_right) self._navbut_forward.setIconSize(QtCore.QSize(16, 16)) self._navbut_forward.setStyleSheet( "QToolButton { border: none; padding: 0px; }") self._navbut_forward.clicked.connect(self.onNavForward) # Create button for sorting self._sortbut = QtWidgets.QToolButton(self) self._sortbut.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon) self._sortbut.setArrowType(QtCore.Qt.DownArrow) self._sortbut.setStyleSheet( "QToolButton { border: none; padding: 0px; }") self._sortbut.setText("A-z") self._sortbut.setToolTip("Sorted") self._sortbut.clicked.connect(self.onSortPress) # Create button for reload self._reload = QtWidgets.QToolButton(self) self._reload.setIcon(pyzo.icons.arrow_refresh) self._reload.setToolTip("Not sorted") self._reload.clicked.connect(self.onReloadPress) # # Create icon for slider # self._sliderIcon = QtWidgets.QToolButton(self) # self._sliderIcon.setIcon(pyzo.icons.text_align_right) # self._sliderIcon.setIconSize(QtCore.QSize(16,16)) # self._sliderIcon.setStyleSheet("QToolButton { border: none; padding: 0px; }") # Create slider self._slider = QtWidgets.QSlider(QtCore.Qt.Horizontal, self) self._slider.setTickPosition(QtWidgets.QSlider.TicksBelow) self._slider.setSingleStep(1) self._slider.setPageStep(1) self._slider.setRange(1, 5) self._slider.setValue(self._config.level) self._slider.valueChanged.connect(self.updateStructure) # Create options button # self._options = QtWidgets.QPushButton(self) # self._options.setText('Options')) # self._options.setToolTip("What elements to show.") 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) # Create options menu self._options._menu = QtWidgets.QMenu() self._options.setMenu(self._options._menu) # Create tree widget self._tree = QtWidgets.QTreeWidget(self) self._tree.setHeaderHidden(True) self._tree.setSortingEnabled(False) self._tree.itemCollapsed.connect(self.updateStructure) # keep expanded self._tree.itemClicked.connect(self.onItemClick) # set widget stye background = self.getThemeItem(item="editor.text") textcolor = self.getThemeItem(item="syntax.identifier") styleKeys = ["background-color", "color"] styleValues = [background["back"], textcolor["fore"]] self.setWidgetStyleSheet(self._tree, styleKeys, styleValues) # Create two sizers self._sizer1 = QtWidgets.QVBoxLayout(self) self._sizer2 = QtWidgets.QHBoxLayout() self._sizer1.setSpacing(2) self._sizer1.setContentsMargins(0, 0, 0, 0) # Set layout self._sizer1.addLayout(self._sizer2, 0) self._sizer1.addWidget(self._tree, 1) # self._sizer2.addWidget(self._sliderIcon, 0) self._sizer2.addWidget(self._reload, 0) self._sizer2.addWidget(self._sortbut, 0) self._sizer2.addWidget(self._navbut_back, 0) self._sizer2.addWidget(self._navbut_forward, 0) self._sizer2.addStretch(1) self._sizer2.addWidget(self._slider, 6) self._sizer2.addStretch(1) self._sizer2.addWidget(self._options, 0) # self.setLayout(self._sizer1) # Init current-file name self._currentEditorId = 0 # Bind to events pyzo.editors.currentChanged.connect(self.onEditorsCurrentChanged) pyzo.editors.parserDone.connect(self.updateStructure) self._options.pressed.connect(self.onOptionsPress) self._options._menu.triggered.connect(self.onOptionMenuTiggered) # Start # When the tool is loaded, the editorStack is already done loading # all previous files and selected the appropriate file. self.onOptionsPress() # Create menu now self.onEditorsCurrentChanged()
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, 'showTypes'): # self._config.showTypes = ['class', 'def', 'cell', 'todo'] # if not hasattr(self._config, 'level'): # self._config.level = 2 # Keep track of sorting order self._sort_order = None # Snippet folder self.snippet_folder = os.path.join(pyzo.appDataDir, "tools", "pyzoSnippetManager", "snippets") # Create button for reload self._reload = QtWidgets.QToolButton(self) self._reload.setIcon(pyzo.icons.arrow_refresh) self._reload.setToolTip("Reload") # event self._reload.clicked.connect(self.onReloadPress) # Create button for sorting self._sortbut = QtWidgets.QToolButton(self) self._sortbut.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon) self._sortbut.setArrowType(QtCore.Qt.DownArrow) self._sortbut.setStyleSheet( "QToolButton { border: none; padding: 0px; }") self._sortbut.setText("A-z") self._sortbut.setToolTip("Sorted") # event self._sortbut.clicked.connect(self.onSortPress) # Create button ofor opening snippet file in the editor self._open_file = QtWidgets.QToolButton(self) self._open_file.setIcon(pyzo.icons.page_white_text) self._open_file.setIconSize(QtCore.QSize(16, 16)) self._open_file.setStyleSheet( "QToolButton { border: none; padding: 0px; }") self._open_file.setToolTip("Open snippet file") # event self._open_file.clicked.connect(self.onOpenFile) # Create options button # 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) # Create options menu # self._options._menu = QtWidgets.QMenu() # self._options.setMenu(self._options._menu) # Create tree widget self._tree = QtWidgets.QTreeWidget(self) self._tree.setColumnCount(2) self._tree.setHeaderLabels(["description", "prefix"]) self._tree.setColumnWidth(0, 350) self._tree.setHeaderHidden(True) self._tree.setSortingEnabled(True) self._tree.sortItems(0, QtCore.Qt.AscendingOrder) # style self.setWidgetTextStyle(self._tree) # Create two sizers self._sizer1 = QtWidgets.QVBoxLayout(self) self._sizer2 = QtWidgets.QHBoxLayout() self._sizer1.setSpacing(2) self._sizer1.setContentsMargins(0, 0, 0, 0) # Set layout self._sizer1.addLayout(self._sizer2, 0) self._sizer1.addWidget(self._tree, 1) # self._sizer2.addWidget(self._sliderIcon, 0) self._sizer2.addWidget(self._reload, 0) self._sizer2.addWidget(self._sortbut, 0) self._sizer2.addStretch(1) self._sizer2.addWidget(self._open_file, 0) # self.setLayout(self._sizer1) # Init current-file name self._currentEditorId = 0 self.fillTree() # Bind to events self._tree.clicked.connect(self.onItemClicked)
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, 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)
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() # coding=utf-8 # self._config = pyzo.config.tools[toolId] # if not hasattr(self._config, 'showTypes'): # self._config.showTypes = ['class', 'def', 'cell', 'todo'] # if not hasattr(self._config, 'level'): # self._config.level = 2 data = {"Firefox search": {"command": "firefox -search %s"}} self.commands_file = os.path.join(DIR, RESULTFILE) if not os.path.exists(self.commands_file): saveCommands(data, DIR, RESULTFILE) # Load commands self.commands_all = loadCommands(DIR, RESULTFILE) # variable self.file_browser = None self.logger = pyzo.toolManager.getTool("pyzologger") self.process = None self.qba = pyzo.QtCore.QByteArray() self.locale_codec = pyzo.QtCore.QTextCodec.codecForLocale() self.name = "" # nraw name string self.command = "" # raw command string self.command_process = "" # command in QProcess self.process_output = "" # # Create button for add external command self._add = QtWidgets.QToolButton(self) self._add.setIcon(pyzo.icons.add) self._add.setToolTip("Add External Command") # event self._add.clicked.connect(self.addCommand) # Create button for edit external command self._edit = QtWidgets.QToolButton(self) self._edit.setIcon(pyzo.icons.application_edit) self._edit.setToolTip("Edit External Command") # event self._edit.clicked.connect(self.editCommand) # Create button for remove external command self._remove = QtWidgets.QToolButton(self) self._remove.setIcon(pyzo.icons.delete) self._remove.setToolTip("Remove External Command") # event self._remove.clicked.connect(self.removeCommand) # Create button to kill process self._terminate = QtWidgets.QToolButton(self) self._terminate.setIcon(pyzo.icons.cross) self._terminate.setToolTip("Terminate") self._terminate.setEnabled(False) # event self._terminate.clicked.connect(self.terminateCommand) # Create button for execute command self._run = QtWidgets.QToolButton(self) self._run.setIcon(pyzo.icons.application_go) self._run.setToolTip("Execute command") # event self._run.clicked.connect(self.start) # Create tree self._tree = QtWidgets.QTreeWidget(self) self._tree.setColumnCount(1) self._tree.setHeaderLabels(["Name"]) self._tree.setColumnWidth(0, 200) self._tree.setHeaderHidden(False) self._tree.setSortingEnabled(True) self._tree.sortItems(1, QtCore.Qt.AscendingOrder) self._tree.setRootIsDecorated(False) # set widget stye background = self.getThemeItem(item="editor.text") textcolor = self.getThemeItem(item="syntax.identifier") styleKeys = ["background-color", "color"] styleValues = [background["back"], textcolor["fore"]] self.setWidgetStyleSheet(self._tree, styleKeys, styleValues) # self.setWidgetStyleSheet(self._tree) # event self._tree.itemDoubleClicked.connect(self.start) # Output message self._output = QtWidgets.QTextBrowser(self) initText = "" self._output.setText(initText) # style self.setWidgetStyleSheet(self._output, styleKeys, styleValues) # Empty label self._empty = QtWidgets.QLabel(self) # Create two sizers self._sizer1 = QtWidgets.QVBoxLayout(self) self._sizer2 = QtWidgets.QHBoxLayout() # self._sizer1.setSpacing(2) self._sizer1.setContentsMargins(0, 0, 0, 0) # Set layout self._sizer1.addLayout(self._sizer2, 0) self._sizer1.addWidget(self._tree, 1) self._sizer1.addWidget(self._output, 1) # self._sizer2.addWidget(self._add, 0) self._sizer2.addWidget(self._edit, 0) self._sizer2.addWidget(self._remove, 0) self._sizer2.addWidget(self._terminate, 0) self._sizer2.addWidget(self._empty, 1) self._sizer2.addWidget(self._run, 0) # self.setLayout(self._sizer1) self.fillTree(self.commands_all)